← All problemsSign in

Queries on Tree

You are given a tree T with N nodes numbered 1 through N. Each node of the tree has a value; let's denote the value of node v by Cv. You are also given Q queries to process. There are two types of queries: - 1 U V W — add W to the value of each node on the path between nodes U and V (both inclusive) - 2 U V X — consider each node on the path between nodes U and V (both inclusive) whose value is

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start