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

建议使用的浏览器:

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

5360:Hiking

Special Judge 特殊评判
题目描述
There are $n$ soda conveniently labeled by $1,2,\dots,n$. beta, their best friends, wants to invite some soda to go hiking. The $i$-th soda will go hiking if the total number of soda that go hiking except him is no less than $l_i$ and no larger than $r_i$. beta will follow the rules below to invite soda one by one:
1. he selects a soda not invited before;
2. he tells soda the number of soda who agree to go hiking by now;
3. soda will agree or disagree according to the number he hears.

Note: beta will always tell the truth and soda will agree if and only if the number he hears is no less than $l_i$ and no larger than $r_i$, otherwise he will disagree. Once soda agrees to go hiking he will not regret even if the final total number fails to meet some soda's will.

Help beta design an invitation order that the number of soda who agree to go hiking is maximum.
输入解释
There are multiple test cases. The first line of input contains an integer $T$, indicating the number of test cases. For each test case:

The first contains an integer $n$ $(1 \le n \le 10^5)$, the number of soda. The second line constains $n$ integers $l_1, l_2, \dots, l_n$. The third line constains $n$ integers $r_1, r_2, \dots, r_n$. $(0 \le l_i \le r_i \le n)$
It is guaranteed that the total number of soda in the input doesn't exceed 1000000. The number of test cases in the input doesn't exceed 600.
输出解释
For each test case, output the maximum number of soda. Then in the second line output a permutation of ${1, 2, \dots, n}$ denoting the invitation order. If there are multiple solutions, print any of them.
输入样例
4
8
4 1 3 2 2 1 0 3
5 3 6 4 2 1 7 6
8
3 3 2 0 5 0 3 6
4 5 2 7 7 6 7 6
8
2 2 3 3 3 0 0 2
7 4 3 6 3 2 2 5
8
5 6 5 3 3 1 2 4
6 7 7 6 5 4 3 5
输出样例
7
1 7 6 5 2 4 3 8
8
4 6 3 1 2 5 8 7
7
3 6 7 1 5 2 8 4
0
1 2 3 4 5 6 7 8
来自杭电HDUOJ的附加信息
Author zimpha@zju
Recommend wange2014

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

源链接: HDU-5360

最后修改于 2020-10-25T23:22:00+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 131072/131072K(Java/Others)