Roots of a Tree
You are given a tree with N nodes, numbered from 1 to N. You need to handle the queiries of the following two types: - + x y. Add a path going from the node x to the node y (or from y to x because it's actually irrelevant). We will never add the path that is already a present one. - - x y. Delete the path going from the node x to the node y. It is guaranteed that such path exists and after its l
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start