cf/mirror

Distinctive Roots in a Tree

CF
1467E2500· grandmaster3s256 MB⌨ stdin/stdout

Examples

Sample 1of 2
Input
5
2 5 1 1 4
1 2
1 3
2 4
2 5
Output
3
Sample 2of 2
Input
5
2 1 1 1 4
1 2
1 3
2 4
2 5
Output
0
1467E.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)
loading graph engine…