411 传统题

[CF1682B] 按位与排序 (AND Sorting)

时间限制
1000ms
内存限制
256MiB
登顶 / 尝试
1/ 1
难度
3
    上传者 标签CodeforcesCF1682普及-位运算贪心

[CF1682B] 按位与排序 (AND Sorting)

You are given a permutation p of integers from 0 to n - 1 (not initially sorted). You may swap p_i and p_j if p_i & p_j = X. Find the maximum X such that p is X-sortable. Constraints: 1 <= t <= 10^4, 2 <= n <= 210^5, sum(n) <= 210^5, 0 <= p_i <= n - 1.