https://atcoder.jp/contests/abc387/tasks/abc387_d

これ

Reply to this note

Please Login to reply.

Discussion

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 😛