CF1416C XOR Inverse

题目描述

给定长度为 $n$ $(1\le n\le3\times 10^5)$ 的数列 $\{a_n\}$ $(0\le a_n\le 10^9)$,请求出最小的整数 $x$ 使 $\{a_n\oplus x\}$ 的逆序对数最少,其中 $\oplus$ 是异或

输入格式

输出格式

说明/提示

In the first sample it is optimal to leave the array as it is by choosing $ x = 0 $ . In the second sample the selection of $ x = 14 $ results in $ b $ : $ [4, 9, 7, 4, 9, 11, 11, 13, 11] $ . It has $ 4 $ inversions: - $ i = 2 $ , $ j = 3 $ ; - $ i = 2 $ , $ j = 4 $ ; - $ i = 3 $ , $ j = 4 $ ; - $ i = 8 $ , $ j = 9 $ . In the third sample the selection of $ x = 8 $ results in $ b $ : $ [0, 2, 11] $ . It has no inversions.