CF2216A.Course Wishes
入门
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
qwqkawaii is registering for $ n $ ( $ n\le 50 $ ) courses. In the registration system, he can submit a course wish for each course, which indicates his priority for taking that course.
Course wishes are divided into $ k+1 $ ( $ k\le 20 $ ) priority levels, where level $ 1 $ is the highest priority and level $ k+1 $ is the lowest.
The first $ k $ wish levels have capacity limits: for each $ 1 \le i \le k $ , at most $ a_i $ courses can be assigned wish level $ i $ . Note that wish level $ k+1 $ has no capacity limit.
Initially, the $ i $ -th course has wish level $ b_i $ , and it is guaranteed that this initial assignment satisfies all capacity limits. Now qwqkawaii wants to adjust all his courses to wish level $ k + 1 $ . To achieve this, he can apply the following operation at most $ 1000 $ times:
- Select a course $ i $ ( $ 1\le i\le n $ ), then increase $ b_i $ by $ 1 $ .
Note that:
- A course at level $ k+1 $ cannot be selected;
- After every single operation, all capacity limits must still be satisfied.
Your task is to construct a valid adjustment sequence with at most $ 1000 $ operations, or report that it is impossible.
输入格式
Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \le t \le 50 $ ). The description of the test cases follows.
The first line of each test case contains two integers $ n $ and $ k $ ( $ 1 \le n \le 50 $ , $ 1 \le k \le 20 $ ) — the number of courses and the number of priority levels (excluding the lowest priority level).
The second line contains $ k $ integers $ a_1, a_2, \ldots, a_k $ ( $ 1 \le a_i \le n $ ) — the capacity limits of the first $ k $ wish levels.
The third line contains $ n $ integers $ b_1, b_2, \ldots, b_n $ ( $ 1 \le b_i \le k+1 $ ) — the initial wish levels of the courses.
It is guaranteed that the initial assignment satisfies all capacity limits.
输出格式
For each test case, if it is impossible to reach the target state, print a single integer $ -1 $ .
Otherwise, print the number of operations $ m $ ( $ 0 \le m \le 1000 $ ) on the first line of output.
Then print one line with $ m $ integers $ u_1, u_2, \ldots, u_m $ ( $ 1 \le u_i \le n $ ), denoting that in the $ i $ -th operation, you increase the wish level $ b_{u_i} $ of course $ u_i $ by $ 1 $ .
输入输出样例
输入#1
4 3 2 2 2 1 2 2 4 2 2 2 3 3 3 3 1 1 1 1 5 3 1 2 3 1 2 4 2 3
输出#1
4 2 1 3 1 0 1 1 8 2 4 1 2 1 1 5 4
说明/提示
In the first test case, initially, the wish levels are $ [1, 2, 2] $ . The capacity limits are $ a_1=2 $ and $ a_2=2 $ . The operations are as follows:
- Increase course $ 2 $ to level $ 3 $ . Now the wish levels are $ [1,3,2] $ .
- Increase course $ 1 $ to level $ 2 $ . Now the wish levels are $ [2,3,2] $ .
- Increase course $ 3 $ to level $ 3 $ . Now the wish levels are $ [2,3,3] $ .
- Increase course $ 1 $ to level $ 3 $ . Now the wish levels are $ [3,3,3] $ , which matches the target.
In the second test case, the initial state is already exactly the target state, so no operations are needed.
输入解题思路,AI测评打分。不知道怎么写?