← All problemsSign in

Miu and The Cat Country

Miu has formed a new country made only for cats. The country consists of $N$ cities **connected** with $N - 1$ **bi-directional** roads. Miu has $Q$ queries. Each query consists of 2 integers $u$ & $v$. Miu wants to find the total number of neighbours (Cities at a distance of 1) of all the cities present in the shortest path from $u$ to $v$ (both inclusive) Note that the cities presen

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