当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6925:Micro Structure Thread

Special Judge 特殊评判
题目描述
Given a sequence $a$ consists $n$ distinct integers. Please construct a permutation $p$ and a sequence $b$ satisfied:

- Both $p$ and $b$ have exactly $n$ elements;
- For every $i \in [2,n]$ ,there exist an indice $j(1 \leq j \leq i-1)$ such that $b_i \oplus p_j=0$.

You need to minimize $\sum\limits_{i=2}^n popcount(a[p[i]] \oplus a[b[i]])$, where $popcount(x)$ represents the number of $1$ in the binary representation of $x$, $\oplus$ means bitwise exclusive OR operation.
输入解释
The input consists of multiple test cases. The first line contains an integer $T$ $(1 \leq T \leq 10)$ — the number of test cases.
The description of the test cases follows.

The first line contains one integers $n$ $(1 \leq n \leq 2*10^5)$ .

The second line contains $n$ distinct integers $a_1,a_2,\dots,a_n(0 \leq a_i < 2^{18})$ .
输出解释
For each test case, print three lines.

The first line contains one number, represents the minimum value.

The second line contains $n$ numbers $p_1,p_2,\dots,p_n$ — the permutation you construct.

The last line contains $n$ numbers $b_1,b_2,\dots,b_n$ — the sequence you construct.

If there are several answers, you can print any.
输入样例
2
3
2 3 4
4
65 23 11 43
输出样例
3
1 2 3 
3 1 1 
7
1 3 4 2 
4 1 3 3 
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6925

最后修改于 2021-06-22T18:18:55+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
16000/8000MS(Java/Others) 262144/262144K(Java/Others)