Moodle Chat
CodeChefOpen on judge ↗
Given a tree having N nodes (rooted at node 1), and values v[i] associated with each node. You have to process q queries. For each query, you are given two nodes u, v. You have to find sum of all nodes in the smallest subtree containing both nodes u and v. As the sum can be large, you have to find sum modulo 109+ 7 Go through example to understand about subtree. Input Format: first line conta
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