← All problemsSign in

City Game

There are $N$ cities in Haryana which are famous for gaming and they are all connected using $N-1$ bi-directional roads. One of the N cities is the capital city of Haryana. Each city has a game value as $Gi$ where $i$ varies from 1 to N. Every city has a parent city except the capital city. The value of parent of the capital city is -1. Yash plans $Q$ trips to visit the different cities. In each t

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