Skip to main content

Practice · 3 of 3

Path Add, Path Sum

CHALLENGE
Difficulty: advanced+25 XP

**Bài toán.** Same input protocol; operations: "1 u v x" — add x to every vertex on the path u..v; "2 u v" — print the SUM of values on the path u..v, one per line. **Constraints:** 1 ≤ n, q ≤ 200 000; |val|, |x| ≤ 10^9 (sums fit in long long). HLD + lazy range-add/range-sum tree. The load test is a bamboo with 2·10^5 path operations — the per-op parent climb times out.

Back to lesson: Practice: HLD Trio