Problem D. Score of a Tree | Codeforces | 845 div2.

Click a thumbnail to watch in a lightweight modal. (No downloads — view only.)