cf/mirror

An easy problem about trees

CF
457F3200· legendary gm2s256 MB⌨ stdin/stdout

Examples

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