Traffic in Chefland
There are N cities in Chefland. Chef owns the biggest traffic company in Chefland, and Chef has built N-1 bidirectional roads between these cities. The i-th road connects city ai and city bi, and is ci kms long. It's possible to travel between any two cities by going through these roads. However, only those people who have Chef's VIP card can use these roads. It costs 1 Chefcoin/km to travel on on
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