Minimise Difference
CodeChefOpen on judge ↗
You're given a simple undirected graph $G$ with $N$ vertices and $M$ edges. You have to assign, to each vertex $i$, a number $C_i$ such that $1 \leq C_i \leq N$ and $\forall i \neq j, C_i \neq C_j$. For any such assignment, we define $D_i$ to be the number of neighbours $j$ of $i$ such that $C_j < C_i$. You want to minimise ${max_{i \in \{1..N\}} D_i} - {min_{i \in \{1..N\}} D_i}$. Output the
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