Primitive Queries
Given a tree T consisting of N nodes and Q queries on it. Each node v have some value Cv assigned to it. The queries can be of two types: - 1 u v - find number of distinct numbers on path between u and v - 2 v y - assign the value y to the node with index v. All the indices in the queries are 1-based. Input The first line of input contains two integers N and Q denoting the number of elem
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