#P9274. [AGM 2023 资格赛] 建设计划
[AGM 2023 资格赛] 建设计划
Problem Description
A group of engineers is planning to build a new factory. To make their factory reliable, they want to produce various items at a constant and steady rate in units per second. They can use different machines to craft these materials. Each machine has its own speed, which affects the crafting process. Each material has its own crafting recipe, and it must be executed on a specific machine.
You are given the description of each machine and the recipes for every required material and intermediate material. You are also given a list of materials that must be produced at a specified rate so that the factory is reliable.
We say a machine configuration is optimal if and only if, after removing any single machine from the configuration, the production rate of at least one material becomes lower than the required rate.
You need to find an optimal configuration.
Input Format
The first line contains an integer , the number of machine types we have. In the next lines, each line contains a string and a number , representing the machine name and its speed.
The next line contains an integer , the number of recipes.
Then follow groups of recipes. For each recipe group: in the first line of the recipe, a string is the name of the material to be crafted, a string is the name of the machine used in the crafting process, and a number is the time (in seconds) required to craft the material at normal speed. On the next line, there is a number , the number of types of additional materials required to produce this material. In the following lines, each line contains a string , the name of a required material, and an integer , the number of units of that material required.
The next line contains an integer , the number of demands.
Each of the next lines contains a string , the name of the material that must be produced for this demand, and an integer , the number of units of that material that must be produced per second.
Both and are floating-point numbers with two decimal places. It is guaranteed that an optimal configuration exists. It is guaranteed that in an optimal solution, the production rate of each material does not exceed units per second, and each material can be crafted using a unique recipe. It is also guaranteed that the dependency graph of recipe requirements has no cycles.
Output Format
Output a total of lines. On the -th line, output , where is the number of machines used to execute the -th recipe.
3
assembler 0.50
furnace 0.50
mining_well 0.55
6
iron_plate furnace 3.20
1
iron_ore 1
copper_plate furnace 3.20
1
copper_ore 1
iron_ore mining_well 1.00
0
copper_ore mining_well 1.00
0
copper_cable assembler 0.50
1
copper_plate 1
electronic_circuit assembler 0.50
2
iron_plate 1
copper_cable 3
1
electronic_circuit 10
iron_plate furnace 64
copper_plate furnace 192
iron_ore mining_well 19
copper_ore mining_well 55
copper_cable assembler 30
electronic_circuit assembler 10
3
assembler 0.50
furnace 0.50
mining_well 0.55
4
iron_plate furnace 3.20
1
iron_ore 1
iron_ore mining_well 1.00
0
iron_gear assembler 0.50
1
iron_plate 2
transport_belt assembler 0.50
2
iron_plate 1
iron_gear 1
1
transport_belt 7
iron_plate furnace 135
iron_ore mining_well 39
iron_gear assembler 7
transport_belt assembler 7
Hint
Translated by ChatGPT 5