cf/mirror

Doremy's Average Tree

CF
1889F3500· legendary gm3s1024 MB⌨ stdin/stdout

Examples

Sample 1of 1
Input
4
6 1 1
1 9 2 6 1 8
1 2
1 3
2 4
3 6
3 5
7 7 2
3 1 3 3 1 1 2
7 1
7 2
7 4
1 5
2 3
4 6
6 5 1
3 1 3 1 1 3
5 3
5 1
5 6
3 4
1 2
3 2 1
1000000 999999 999997
2 1
1 3
Output
1
2
2
1 4
1
5
1
1
1889F.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)
loading graph engine…