#P94. [NOI 2025 Day 1] 机器人
[NOI 2025 Day 1] 机器人
Person in Charge
Problem Description
NOI2025 is being held in Shaoxing, and Little Y has built a robot for the closing ceremony performance and plans to control it to move from the warehouse to the auditorium.
The road system in Shaoxing can be simplified as intersections and one-way roads connecting these intersections, each with a certain length. To facilitate the input of the road system into the robot's chip, Little Y has numbered all the roads originating from each intersection. Specifically, if there are roads starting from intersection , these roads will be numbered by Little Y in some order as , referred to as the to roads starting from .
Little Y's robot has an internal parameter . Given the upper limit of the parameter and the modification costs , Little Y will set and modify the robot's parameter according to the following rules:
- Initially, Little Y sets the parameter to .
- At any time, Little Y can remotely control the robot to modify the parameter:
- If , Little Y can spend to increase by , i.e., ;
- If , Little Y can spend to decrease by , i.e., .
Initially, Little Y's robot is located at the robot warehouse, which is intersection . When the robot is at intersection , let the road starting from intersection have destination and length . Then, Little Y can spend to control the robot to move from to . Specifically, if there are fewer than roads starting from intersection , Little Y cannot control the robot to move.
Little Y does not know which intersection the auditorium for the closing ceremony is located at, so he needs to prepare for every intersection. Please help him determine the minimum cost required to move the robot from the warehouse to each intersection.
Input Format
The first line of input contains a non-negative integer , representing the test case number. indicates that the test case is a sample.
The second line of input contains three positive integers , representing the number of intersections, the number of roads, and the upper limit of the parameter .
The third line of input contains non-negative integers , representing the costs to increase the parameter .
The fourth line of input contains non-negative integers , representing the costs to decrease the parameter .
The line of input (for ) contains several positive integers. The first non-negative integer represents the number of roads starting from intersection , followed by positive integers $y_{i,1}, z_{i,1}, y_{i,2}, z_{i,2}, \ldots, y_{i,d_i}, z_{i,d_i}$, representing the roads starting from intersection , where (for ) represent the destination and length of the road, respectively.
Output Format
Output one line containing integers, where the integer (for ) represents the minimum cost required for Little Y to move the robot from the warehouse to intersection . Specifically, if the robot cannot be moved to the intersection, output .
Samples
0
5 6 3
2 4
1 1
3 2 5 3 1 4 2
1 3 2
2 1 2 4 1
0
0
0 5 3 4 -1
Sample 1 Explanation
Little Y can use the following plans to move the robot from the warehouse to intersections :
- For intersection : The robot is initially at intersection , so the cost is .
- For intersection : Little Y controls the robot to move along the road starting from intersection to intersection , with a cost of .
- For intersection : Little Y increases the parameter by , then controls the robot to move along the road starting from intersection to intersection , with a cost of .
- For intersection : Little Y increases the parameter by , then controls the robot to move along the road starting from intersection to intersection , and then moves along the road starting from intersection to intersection , with a cost of .
It can be proven that the costs of the above plans are all minimal.
- For intersection : Since Little Y cannot move the robot to intersection , the output is .
Sample 2
See the files robot/robot2.in and robot/robot2.ans in the contestant directory.
This sample satisfies the constraints of test cases .
Sample 3
See the files robot/robot3.in and robot/robot3.ans in the contestant directory.
This sample satisfies the constraints of test cases .
Sample 4
See the files robot/robot4.in and robot/robot4.ans in the contestant directory.
This sample satisfies the constraints of test cases .
Sample 5
See the files robot/robot5.in and robot/robot5.ans in the contestant directory.
This sample satisfies the constraints of test cases .
Data Range
For all test data, the following guarantees hold:
- , ;
- For all , ;
- For all , ;
- For all , , and ;
- For all , , , .
| Test Case | Special Properties | ||
|---|---|---|---|
| C | |||
| None | |||
| AB | |||
| A | |||
| C | |||
| None | |||
- Special Property A: and .
- Special Property B: For all , , .
- Special Property C: At most intersections satisfy .