← All problemsSign in

Groot and Trees

Groot loves trees, and this new challenge has him stumped! Consider a tree, t, consisting of n nodes. Each node is numbered from 1 to n , and each node has an integer〖 c〗_i , attached to it. A query on tree t takes the form w x y z. To process a query, you must print the count of ordered pairs of integers ( i,j) such that the following four conditions are all satisfied: i ≠j i ∈the path from node

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