#P6775. [NOI2020] 制作菜品
[NOI2020] 制作菜品
Description
A chef plans to cook dishes for kids, and each dish uses grams of ingredients. For this purpose, the chef bought types of ingredients, numbered from to . The mass of ingredient type is grams. The total mass of all ingredients is exactly grams, where both and are positive integers.
When cooking, one type of ingredient may be used in multiple dishes. However, to make the taste purer, the chef decides that each dish uses at most types of ingredients. Now you need to determine whether there exists a cooking plan that satisfies the requirements. More specifically, the plan must satisfy:
- A total of dishes are made.
- Each dish uses at most types of ingredients.
- Each dish uses exactly grams of ingredients.
- The amount of each ingredient used in each dish is a positive integer number of grams.
- All types of ingredients are used up exactly.
If such a plan exists, you also need to output one specific plan.
Input Format
This problem contains multiple test cases in a single test file.
The first line contains an integer denoting the number of test cases. For each test case:
- The first line contains three positive integers , representing the number of ingredient types, the number of dishes to cook, and the grams of ingredients needed per dish.
- The second line contains integers; the -th integer denotes , the mass of ingredient type .
Output Format
For each test case:
- If no feasible cooking plan exists, output one line with the integer .
- Otherwise, output lines, each describing one dish. Depending on how many ingredient types are used, the format is one of the following:
- Output two integers and , meaning this dish uses grams of ingredient type . You must ensure and .
- Output four integers , , , and , meaning this dish uses grams of ingredient type and grams of ingredient type . You must ensure , , , and .
This problem uses a custom checker to verify your output, so if multiple valid plans exist, you only need to output any one of them.
You must ensure the output format is correct. Adjacent numbers on the same line must be separated by exactly one space, and your output must not contain any other extra characters.
4
1 1 10
10
4 3 100
80 30 90 100
5 3 1000
200 400 500 900 1000
6 4 100
25 30 50 80 95 120
1 10
1 80 2 20
2 10 3 90
4 100
-1
1 5 5 95
1 20 4 80
2 30 6 70
3 50 6 50
Hint
Sample 1 Explanation
For the second test case, one feasible cooking plan is:
- Use grams of ingredient and grams of ingredient to make the first dish.
- Use grams of ingredient and grams of ingredient to make the second dish.
- Use grams of ingredient to make the third dish.
Sample 2
See dish/dish2.in and dish/dish2.ans in the contestant directory.
Sample 3
See dish/dish3.in and dish/dish3.ans in the contestant directory.
Constraints
For all test cases: , , , , , .
The specific limits for each test point are shown in the table below:
| Test Point ID | |||
|---|---|---|---|
Translated by ChatGPT 5
京公网安备 11011102002149号