← All problemsSign in

Distance Multiplier

CodeChefRating 3336Open on judge ↗

You have a **simple weighted complete undirected** graph on a vertex set with $N$ vertices, numbered $1$ to $N$. The weights follow a special property as described below. You are given an array $A$ of size $N$ ($1 \le A_i \le 20$), and the weight of the edge joining vertices $X$ and $Y$ can be described as follows: - If $A_X = A_Y$, the weight is $|X - Y|$ - If $A_X \ne A_Y$, the weight is $2 \c

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