cf/mirror

Recover a functional graph

CF
739D3400· legendary gm2s256 MB⌨ stdin/stdout

Examples

Sample 1of 6
Input
3
0 3
0 3
? ?
Output
2 3 1
Sample 2of 6
Input
5
3 2
? ?
? ?
? ?
? ?
Output
5 3 2 2 4
Sample 3of 6
Input
8
? 3
? ?
0 2
0 2
0 3
0 3
0 3
3 3
Output
5 1 4 3 6 7 5 2
Sample 4of 6
Input
1
? ?
Output
1
Sample 5of 6
Input
6
0 3
0 3
0 3
0 3
0 3
0 3
Output
2 3 1 5 6 4
Sample 6of 6
Input
2
1 1
1 1
Output
-1
739D.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)