[NOIP Simulation Test]: big (Trie tree greedy +)

Title Description

You need $ [0,2 ^ n) $ integer selected a $ x $, then the $ X $ $ m $ XOR sequentially integer $ a_1 ~ a_m $.
After you select $ x $, your opponent need to choose just a moment (just finished selecting the number, or the number of different number or the last), the $ x $ becomes $ (\ left \ lfloor {\ frac { 2 \ times x} {2 ^ n}} \ right \ rfloor \ mod 2 ^ n) $ you want to make $ x $ Finally as large as possible, while your opponent will make the final $ x $ as small as possible.
You need to find the last of the maximum $ x $, and get the maximum amount of the initial value.


Input Format

The first line of two integers $ n, m $.
The second row integer $ m $ $ a_1 ~ a_m $.


Output Format

The first output line an integer representing the maximum value of the last $ x $.
The second output line an integer representing the number of the initial value to give the maximum.
The first number to obtain the correct $ 6 $ points, two numbers are correct then get $ 4 $ points.


Sample

Sample input

2 3
1 2 3

Sample Output

1
2


Data range and tips

Sample explained:

Obtained when $ x = 0 $ $ 0 $, $ x = $ 1 $ obtained when 1 $, $ x = 2 $ get $ 1 $, $ x = 0 to obtain $ $ $ 3.

data range:

For the data of $ 20% $, $ n \ leqslant 10 $, $ m \ leqslant 100 $.
For the data of $ 40% $, $ n \ leqslant 10 $, $ m \ leqslant 1,000 $.
For another 20% of $ $ data, $ n \ leqslant 30 $, $ m \ leqslant 10 $.
For the data of $ 100% $, $ n \ leqslant 30 $, $ m \ leqslant 100,000 $, $ 0 \ leqslant a_i <2 ^ n $.


answer

Note that the above equation that magical: $ (\ left \ lfloor {\ frac {2 \ times x} {2 ^ n}} \ right \ rfloor \ mod 2 ^ n) $.

Look ignorant just a look, a closer look or a look ignorant ...... ......

In fact, not so difficult, this question is the $ x $ was a logical shift left, in fact, that the $ x $ left a bit, and up to a maximum of the last.

Then we come back about the formula:

  First set $ q [i] $ $ denotes exclusive or prefix, and A $ array.

  那么:$ans=((x\ xor\ a_i)\ll 1)xor(a_i\ xor\ a_m)$。

  展开:$ans=(x\ll 1)xor(a_i\ll 1)xor\ a_i\ xor\ a_m$。

Guess you like

Origin www.cnblogs.com/wzc521/p/11288658.html