##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
| # | Title | Points | Solved | Admin | |
|---|---|---|---|---|---|
You are given a tree with vertices, numbered from to . Vertex has a label . The labels are not necessarily distinct.
Choose one vertex as the root of the tree. This determines the parent and children of every vertex.
A vertex is called unhappy if both of the following conditions hold:
Find the minimum possible number of unhappy vertices, and the number of choices of the root for which this minimum is attained.
If vertex or vertex is chosen as the root, every vertex with at least one child also has a child whose label is smaller than its own label. Therefore, there are no unhappy vertices for either of these two roots.
Choosing vertex , , or as the root creates exactly one unhappy vertex. Choosing either endpoint as the root creates two unhappy vertices, so the minimum is and it is attained by three roots.
For every choice of the root except vertex , there are no unhappy vertices. Notice that vertices and have equal labels, so neither label is strictly greater than the other.