← All problemsSign in

Connected or not

There are $N$ cities. Initially no city is connected to any other city. But a city can be connected to other city by building a bridge.Each city can build at most one bridge.You have to find out whether we can reach city B from city A. There can be 2 types of queries. - Type 1:- City $A$ build bridge to City $B$. - Type 2:- To check whether we can reach City $B$ from City $A$. ###Input: - Fi

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