Shopping Battles
CodeChefOpen on judge ↗
There are n - shops in the city, the i-th shop belongs to the ai -th owner. Initially, no shops are connected to each other. You are the Public Representative of the city and want to build (n−1) two-way roads to connect all shops (two shops can be connected directly or through other connected shops)for the convenience of the people living in the city. If two shops belonging to the same owner are
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