#P6635. 「JYLOI Round 1」箭头调度
「JYLOI Round 1」箭头调度
Description
moyu_028 gives you an undirected graph with vertices and edges. Now you need to assign a direction to each edge. Please find a direction assignment such that a topological order can be generated under this assignment, and this topological order is the -th smallest in lexicographical order among all possible topological orders.
Input Format
The first line contains three positive integers , , and , as described above.
Then there are lines. The -th line contains two positive integers and , indicating an undirected edge between and .
Output Format
Output one line containing a 01 string of length . The -th character indicates the direction of the undirected edge between and . If it is 0, the edge is directed from to ; if it is 1, the edge is directed from to . It can be proven that the answer is unique, and the testdata guarantees that a solution exists.
6 7 5
1 3
2 1
4 2
4 3
4 5
3 6
5 6
0111001
11 20 20091210
2 3
3 1
2 5
4 6
7 9
8 10
8 1
7 2
2 3
3 2
4 5
5 7
7 6
7 8
9 7
9 8
10 2
2 3
1 3
1 7
10110000100110110111
Hint
Topological order: In a DAG (Directed Acyclic Graph), we sort the vertices in a linear order such that for every directed edge from vertex to vertex , appears before . Such a sequence is called a topological order.
Sample Explanation
Sample 1 Explanation
The graph of the answer is as follows. The answer can be obtained from the graph.

Constraints
For of the testdata, , , , , .
For test point 1 (10 points): .
For test point 2 (30 points): , .
For test point 3 (30 points): , .
For test point 4 (30 points): no special constraints.
This problem has 4 test points, with a total score of 100 points. The time limit for each test point is 5 seconds.
Source
"JYLOI Round 1" A
Idea: moyu_028 & abcdeffa
Solution: LiuXiangle
Data: abcdeffa
Translated by ChatGPT 5
京公网安备 11011102002149号