European Girls' Olympiad in Informatics: 2023 Day 2 Problem 3
Grushög is an unfinished residential area in the outskirts of Lund. Right now, all necessary infrastructure is being constructed, including the most important thing of all: garbage disposal. Like in many areas of Sweden, a sopsug (automated vacuum collection system) will be used to collect garbage. The idea is to transport garbage underground through tubes using air pressure.
There are
However,
Furthermore, there are
Input Specification
The first line of input contains the three integers,
The following
The following
All of the
Output Specification
If there is no solution, print NO
.
Otherwise, print
Limits and Scoring
. . . for . for .
Your solution will be tested on a set of test groups, each worth a number of points. Each test group contains a set of test cases. To get the points for a test group you need to solve all test cases in the test group.
Group | Score | Limits |
---|---|---|
1 | 12 | |
2 | 10 | |
3 | 19 | |
4 | 13 | |
5 | 17 | It is guaranteed that there is a solution with |
6 | 11 | |
7 | 18 | No additional constraints |
Example
The following figures show the first and second sample test cases. The blue edges mark tubes which are already constructed, and the dashed red edges mark tubes which are impossible to build.
The figure to the left shows the first sample with the solution from the sample output, showing tubes with black edges (in addition to the already constructed tube from
For the second sample input, we can see in the right figure that it is impossible to construct a solution because of the cycle
Sample Input 1
5 1 8
4 1
3 1
3 4
3 2
0 2
0 4
2 4
1 0
2 0
Sample Output 1
4 1
3 0
1 3
2 3
Sample Input 2
5 4 0
1 0
2 3
3 4
4 2
Sample Output 2
NO
Sample Input 3
3 0 1
0 1
Sample Output 3
1 0
2 0
Sample Input 4
4 0 2
0 1
1 0
Sample Output 4
2 0
3 0
1 3
Comments