cf/mirror

Li Hua and Tree

CF
1797D1900· candidate master2s256 MB⌨ stdin/stdout

Examples

Sample 1of 2
Input
7 4
1 1 1 1 1 1 1
1 2
1 3
2 4
2 5
3 6
6 7
1 6
2 3
1 6
1 2
Output
2
3
3
Sample 2of 2
Input
10 14
-160016413 -90133231 -671446275 -314847579 -910548234 121155052 -359359950 83112406 -704889624 145489303
1 6
1 10
10 8
1 4
3 4
2 7
2 5
3 2
9 8
1 4
2 2
2 4
1 4
1 10
2 10
1 9
1 6
2 8
2 10
1 5
1 8
1 1
2 5
Output
-2346335269
-314847579
-476287915
-704889624
121155052
-1360041415
228601709
-2861484545
1797D.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)
loading graph engine…