#P3254. 圆桌问题
圆桌问题
Description
There are representatives from different units attending an international conference. The -th unit sends representatives.
The conference restaurant has tables, and the -th table can seat representatives.
To encourage communication, representatives from the same unit should not dine at the same table. Please provide a dining arrangement that satisfies this requirement.
Input Format
The first line contains two integers separated by a space, representing the number of units and the number of tables . The second line contains integers separated by spaces, where the -th integer represents the number of representatives in the -th unit. The third line contains integers separated by spaces, where the -th integer represents the capacity of the -th table.
Output Format
This problem uses Special Judge. Output whether a valid arrangement exists. If it exists, output any valid arrangement. The first line contains a single integer, either or . Output if a valid arrangement exists; otherwise, output . If it exists, then for lines to , on line output integers, representing the table indices where the representatives of the -th unit will dine.
4 5
4 5 3 5
3 5 2 6 4
1
1 2 4 5
1 2 3 4 5
2 4 5
1 2 3 4 5
Hint
- Constraints:
- For of the testdata, , , .
- Hint:
- Note that the first line of input reads first, then .
Translated by ChatGPT 5
京公网安备 11011102002149号