cf/mirror

Timofey and a tree

CF
763A1600· expert2s256 MB⌨ stdin/stdout

Examples

Sample 1of 3
Input
4
1 2
2 3
3 4
1 2 1 1
Output
YES
2
Sample 2of 3
Input
3
1 2
2 3
1 2 3
Output
YES
2
Sample 3of 3
Input
4
1 2
2 3
3 4
1 2 1 2
Output
NO
763A.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)
loading graph engine…