← All problemsSign in

Montu the destroyer

Montu is a village destroyer. Now there are N settlements in a village , and every settlement has 8 houses. Every house is represented as a binary number. Two houses (a,b) or (b,a) [order does not matter] are connected if their binary representation differs by a bit. Cost of destroying the village is total cost of all edges. Cost of each edge is initially 0 .But as usual a hero Nicks comes along

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