#P11486. 「Cfz Round 5」Mata rainen
「Cfz Round 5」Mata rainen
Description
Please determine whether there exists a tree that satisfies the following conditions. If so, please try to construct it.
The tree contains vertices numbered from to . Additionally, pairs of vertices are given, and it is required that these paths from vertex to vertex cover each edge exactly once .
If you correctly determine whether there is a solution but cannot construct the tree, you can still obtain some points. See Scoring Method part for details.
A path from vertex to vertex covers an edge if and only if edge is on the shortest path from vertex to vertex .
Input Format
The first line contains two integers and , representing the number of vertices in the tree and the number of given vertex pairs.
The next lines each contain two integers and , representing a pair of vertex.
Output Format
The first line should output a string "Yes" or "No" (case-insensitive) indicating whether there is a solution.
If there is a solution, continue to output lines, each containing two integers and , describing an edge. You need to ensure that and that all edges form a tree.
6 2
1 2
3 4
Yes
1 5
2 5
3 5
4 6
5 6
3 3
1 2
2 3
1 3
No
Hint
Sample Explanation #1

The top left diagram shows the tree given in the sample output. Edges and are covered by path , and edges , , and are covered by path , which meets the problem requirements.
In the top right diagram, edge is covered by both paths and , which does not meet the problem requirements.
In the bottom left diagram, edge is not covered by any path, which does not meet the problem requirements.
The bottom right diagram is not a tree, which does not meet the problem requirements.
Sample Explanation #2
It can be proven that there is no tree that meets the requirements.
Scoring Method
This problem uses special judge for evaluation.
For each test case:
- If the first line has the wrong format or does not match the answer (case-insensitive), you will receive of the points.
- If the first line is correct and says "No", you will receive of the points.
- If the first line is correct and says "Yes", but the format of the following lines is incorrect, you will receive of the points. Therefore, please ensure that the output forms a tree.
- If the first line is correct and says "Yes", the format of the following lines is correct, but the tree does not meet the requirements, you will receive of the points.
- If the first line is correct and says "Yes", the format of the following lines is correct, and the tree meets the requirements, you will receive of the points.
That is, for the first sample, on the basis of correctly outputting "Yes", outputting the top left diagram will give full points, outputting the top right and bottom left diagrams will give of the points, and outputting the bottom right diagram will not give any points; for the second sample, correctly outputting "No" will give full points.
Constraints
For all test data, it is guaranteed that:
- ;
- ;
- and .
Subtasks are used in this task.
- Subtask 0 (10 points): , .
- Subtask 1 (10 points): , .
- Subtask 2 (20 points): .
- Subtask 3 (10 points): , .
- Subtask 4 (10 points): , .
- Subtask 5 (20 points): .
- Subtask 6 (20 points): No further restrictions.
- Subtask 7 (0 points): Test cases added after the contest.
京公网安备 11011102002149号