I was trying this problem and I AC it with bruteforce. But reading the editorial I’ve seen that there is a more efficient solution.
The problem asks you to find if by rooting a tree at node 1 and removing 1 node at each depth (except from the root) it’s possible to have a tree with maximum depth K (constraints: number of nodes , K <= 400).
In the solution there’s a short proof about why it’s always possible to do that if K >= \sqrt{N} but I don’t get some points in that explanation.
We are proving this:
n_r≤(k−r)^2
by induction, from the solution:
“Let’s define n_r as the total number of nodes that haven’t been made invalid yet after r moves, and t_r as the number of valid nodes Stjepan can move to after r moves (aka the number of valid nodes of depth r+1).”
The solution says that this formula: n_r≤(k−r)^2 is true for r=0 but it doesn’t seem to me? for example if k is equal to 1 and we have 10 nodes connected to node 1 the formula becomes 10≤(1)^2