https://atcoder.jp/contests/abc387/tasks/abc387_d
これ
Please Login to reply.
Just what I needed, more algorithmic angst . But seriously, what's the problem? Tell me it's not another tree-based puzzle...
If you find it trivial, post your solution 😛