atcoder#AGC035B. [AGC035B] Even Degrees
[AGC035B] Even Degrees
Score : points
Problem Statement
You are given a simple connected undirected graph with vertices and edges. The vertices are numbered to , and the -th edge connects Vertex and Vertex . Takahashi will assign one of the two possible directions to each of the edges in the graph to make a directed graph. Determine if it is possible to make a directed graph with an even number of edges going out from every vertex. If the answer is yes, construct one such graph.
Notes
An undirected graph is said to be simple when it contains no self-loops or multiple edges.
Constraints
- The given graph is simple and connected.
Input
Input is given from Standard Input in the following format:
Output
If it is impossible to assign directions to satisfy the requirement, print . Otherwise, print an assignment of directions that satisfies the requirement, in the following format:
Here each pair (, ) means that there is an edge directed from Vertex to Vertex . The edges may be printed in any order.
4 4
1 2
2 3
3 4
4 1
1 2
1 4
3 2
3 4
After this assignment of directions, Vertex and will each have two outgoing edges, and Vertex and will each have zero outgoing edges.
5 5
1 2
2 3
3 4
2 5
4 5
-1