atcoder#ABC236D. [ABC236D] Dance
[ABC236D] Dance
Score : points
Problem Statement
people numbered attend a ball. They will group into pairs and have a dance.
If Person and Person pair up, where is smaller than , the affinity of that pair is . If the pairs have the affinity of , the total fun of the ball is the bitwise XOR of them: .
Print the maximum possible total fun of the ball when the people can freely group into pairs.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum possible total fun of the ball.
2
4 0 1
5 3
2
6
Let denote a pair of Person and Person . There are three ways for the four people to group into two pairs, as follows.
- Group into . The total fun of the ball here is .
- Group into . The total fun of the ball here is .
- Group into . The total fun of the ball here is .
Therefore, the maximum possible total fun of the ball is .
1
5
5
There will be just a pair of Person and Person , where the total fun of the ball is .
5
900606388 317329110 665451442 1045743214 260775845 726039763 57365372 741277060 944347467
369646735 642395945 599952146 86221147 523579390 591944369 911198494 695097136
138172503 571268336 111747377 595746631 934427285 840101927 757856472
655483844 580613112 445614713 607825444 252585196 725229185
827291247 105489451 58628521 1032791417 152042357
919691140 703307785 100772330 370415195
666350287 691977663 987658020
1039679956 218233643
70938785
1073289207