← All problemsSign in

Maximise the bridges

CodeChefRating 1972Open on judge ↗

Chef is given two integers $N$ and $M$. Please help Chef find any **connected undirected graph** $G$ consisting of exactly $N$ vertices and $M$ edges, such that the number of bridges in $G$ is **maximized** (among all graphs with $N$ vertices and $M$ edges). $G$ **cannot** have [self-loops](https://en.wikipedia.org/wiki/Loop_(graph_theory)) or [multiple edges](https://en.wikipedia.org/wiki/Multipl

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