cf/mirror

Cost of Tree

CF
2192D1800· expert3s256 MB⌨ stdin/stdout

Examples

Sample 1of 1multi-test • hover to link
Input
3
5
1 3 2 1 2
1 2
2 3
3 4
3 5
7
1 2 3 1 3 2 1
1 2
2 3
3 4
4 5
4 6
3 7
5
5 4 3 2 1
1 2
2 3
3 4
4 5
Output
18 10 5 0 0
40 28 18 8 0 0 0
20 10 4 1 0
2192D.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)
loading graph engine…