아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Maximaze XOR sum

시간 제한1초메모리 제한512 MB

요약
배열 A와 B에서 각 위치의 원소를 바꿀지 정해 X(A) + X(B)가 최대가 되도록 하고, 최댓값과 바꿀 위치들을 출력한다. X는 배열 전체의 XOR이다.
난이도

보통10점 중 7점

유형
비트 연산, 그리디, 수학, 구현
정답자
아직 제출이 없습니다

문제

Let us use ⊕\oplus as the symbol for the operation of bitwise "exclusive or" for integers. In C++ and Java it is denoted by the character "\char 94", in Pascal and Python --- by the keyword "xor". For example, 9⊕3=1001_2⊕11_2=1010_2=109 \oplus 3 = 1001\_2 \oplus 11\_2 = 1010\_2 = 10.

You are given two integer arrays AA and BB of length nn. Let's denote X(A)X(A) as the result of calculating bitwise "exclusive or" for all elements of the array: X(A)=A_1⊕A_2⊕…⊕A_nX(A) = A\_1 \oplus A\_2 \oplus \ldots \oplus A\_n. Simiarly, let's denote X(B)=B_1⊕B_2⊕…⊕B_nX(B) = B\_1 \oplus B\_2 \oplus \ldots \oplus B\_n.

For each ii from 11 to nn, it is allowed to swap elements A_iA\_i and B_iB\_i. You must find out which elements should be swapped in order for the sum X(A)+X(B)X(A) + X(B) to be maximum possible.

입력

The first line contains an integer nn --- the size of the arrays (1≤n≤1051 \le n \le {10}^5). The next line contains nn integers A_iA\_i --- elements of the array AA (0≤A_i≤10180 \le A\_i \le {10}^{18}). The next line contains the array BB in the same format.

출력

The first line of output must contain the maximum possible sum X(A)+X(B)X(A) + X(B) and an integer kk --- the number of required swaps. The next line must contain kk different integers from 11 to nn --- indices of the elements to be swapped.

힌트

In the example after the swap the arrays are A=\[2,1]A = \[2, 1] and B=\[1,2]B = \[1, 2].

X(A)=2⊕1=10_2⊕1_2=11_2=3X(A) = 2 \oplus 1 = 10\_2 \oplus 1\_2 = 11\_2 = 3, X(B)=3X(B) = 3, X(A)+X(B)=6X(A) + X(B) = 6.

예제1

  1. 예제 1

    입력
    2
    1 1
    2 2
    
    예상 출력
    6 1
    1