bzoj#P3943. [USACO 2015 Feb] SuperBull
[USACO 2015 Feb] SuperBull
Description
Bessie and her friends are playing hoofball in the annual Superbull championship, and Farmer John is in charge of making the tournament as exciting as possible.
A total of teams are playing in the Superbull. Each team is assigned a distinct integer team ID to distinguish it from the other teams. The Superbull is an elimination tournament -- after every game, Farmer John chooses which team to eliminate from the Superbull, and the eliminated team can no longer play in any more games. The Superbull ends when only one team remains.
Farmer John notices a very unusual property about the scores in matches! In any game, the combined score of the two teams al ways ends up being the bitwise exclusive OR (XOR) of the two team IDs. For example, if teams and were to play, then points would be scored in that game, since .
Farmer John believes that the more points are scored in a game, the more exciting the game is. Because of this, he wants to choose a series of games to be played such that the total number of points scored in the Superbull is maximized. Please help Farmer John organize the matches.
Input Format
The first line contains the single integer .
The following lines contain the team IDs.
Output Format
Output the maximum possible number of points that can be scored in the Superbull.
4
3
6
9
10
37
Limit and Hint
For of testcases, and all ID satisfy .
Source
USACO February 2015 Contest Silver T3