#P7228. [COCI 2015/2016 #3] MOLEKULE
[COCI 2015/2016 #3] MOLEKULE
Description
There are vertices and undirected edges. Define the cost of a directed graph as the length of the longest path in this directed graph.
Now assign directions to these undirected edges so that the cost of the resulting directed graph is minimized.
Output one such direction assignment.
Input Format
The first line contains an integer , the number of vertices.
The next lines each contain two integers , representing an edge.
Output Format
Output lines, each containing one integer :
- If , it means the direction is from to .
- If , it means the direction is from to .
3
1 2
2 3
1
0
4
2 1
1 3
4 1
0
1
0
Hint
Explanation of Sample 1
As shown in the figure:

The cost of this graph is . Note that is also an optimal solution.
Explanation of Sample 2
As shown in the figure:

Constraints
For of the testdata, .
For of the testdata, , .
This problem uses Special Judge.
You only need to output any valid solution.
Notes
Translated from COCI 2015-2016 #3 C MOLEKULE.
Translated by ChatGPT 5
京公网安备 11011102002149号