First find the euler path of the tree and then the rest of the problem is fairly easy. You can use a persistent segment tree to handle the update-query or you can just use the policy based data structures.

Statistics

84% Solution Ratio
YouKnowWhoEarliest, Apr '20
Kuddus.6068Fastest, 0.1s
user.2599Lightest, 12 MB
steinumShortest, 814B
Toph uses cookies. By continuing you agree to our Cookie Policy.