#d2809. 最后的舞会
最后的舞会
The Last Dance
Problem Description
The teacher is throwing a farewell dance for the graduating students. students will attend and be paired into dancing couples. Each student has a number; if student is paired with student , the satisfaction of that couple is (for ). The satisfaction of the whole ball is defined as the XOR sum of the satisfaction of every couple: after the students are split into groups, with the -th couple having satisfaction , the ball's satisfaction is .
Find the maximum possible satisfaction of the ball.
Input Format
The first line gives : there are students at the dance.
Then follows a matrix giving the satisfaction when and are paired:
A_{1,2}, A_{1,3}, ... A_{1,2N}
A_{2,3}, ... A_{2,2N}
...
A_{2N-1,2N}
where and .
Output Format
Output the maximum possible satisfaction of the ball.
Sample Input
2
4 0 1
5 3
2
Sample Output
6
Sample Explanation
- If : $\mathit{ans} = A_{1,2} \oplus A_{3,4} = 4 \oplus 2 = 6$
- If : $\mathit{ans} = A_{1,3} \oplus A_{2,4} = 0 \oplus 3 = 3$
- If : $\mathit{ans} = A_{1,4} \oplus A_{2,3} = 1 \oplus 5 = 4$
The answer is .