cf/mirror

Intersecting Subtrees

CF
1044B1900· candidate master2s256 MB⇄ interactive

Examples

Sample 1of 2
Input
1
3
1 2
2 3
1
1
1
2
2
1
Output
A 1
B 2
C 1
Sample 2of 2
Input
2
6
1 2
1 3
1 4
4 5
4 6
4
1 3 4 5
3
3 5 2
3
6
1 2
1 3
1 4
4 5
4 6
3
1 2 3
3
4 1 6
5
Output
B 2
C 1
A 1
C -1
1044B.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)
loading graph engine…