cf/mirror

1-1-1, Free Tree!

CF
2126F2000· candidate master4s256 MB⌨ stdin/stdout

Examples

Sample 1of 1
Input
4
1 1
1
1 1
2 3
1 1
1 2 10
1 2
2 2
1 1
5 4
1 2 1 2 3
1 2 5
2 3 3
2 4 4
4 5 7
3 2
5 2
1 2
2 3
4 3
1 1 2 2
1 2 2
2 3 6
2 4 8
3 1
4 1
2 2
Output
0
10
0
10
12
5
0
12
8
0
16
2126F.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)
loading graph engine…