#P2763. 试题库问题
试题库问题
Description
Problem description: Assume a question bank contains questions. Each question is labeled with one or more types. We need to select questions from the bank to form an exam paper, and the paper must include the specified numbers of questions of each type. Design an algorithm that meets this requirement.
Programming task: Given the selection requirements, compute a selection plan that satisfies them.
Input Format
The first line contains two positive integers and . Here, is the total number of types in the question bank, and is the total number of questions.
The second line contains positive integers; the -th integer is the required count of type questions. The sum of these numbers is the total number of questions to select, .
Each of the next lines gives the type information for one question. The first positive integer indicates that the question belongs to types, followed by integers that are the type IDs of the question.
Output Format
Output lines. On the -th line, print i: followed by the indices of the selected questions of type . If multiple valid solutions exist, output any one of them. If no solution exists, output No Solution!.
3 15
3 3 4
2 1 2
1 3
1 3
1 3
1 3
3 1 2 3
2 2 3
2 1 3
1 2
1 2
2 1 2
2 1 3
2 1 2
1 1
3 1 2 3
1: 1 6 8
2: 7 9 10
3: 2 3 4 5
Hint
, .
Thanks to @PhoenixEclipse for providing the SPJ.
Translated by ChatGPT 5
京公网安备 11011102002149号