← All problemsSign in

Bear and Clique Distances

CodeChefRating 1972Open on judge ↗

Bearland consists of N cities, numbered 1 through N. Cities are connected with bidirectional roads. Cities 1 through K were built a long time ago, when citizens liked order and regularity. Each pair of those old cities is connected with a road of length X. Note that this description generates K*(K-1)/2 roads. There are M newer roads, not necessarily of the same lengths. The i-th of them connects

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