← All problemsSign in

Egg-free DAG

CodeChefRating 2693Open on judge ↗

Let's call a directed graph *egg-free* if it is acyclic and for any three pairwise distinct vertices $x$, $y$ and $z$, if the graph contains edges $x \rightarrow y$ and $x \rightarrow z$, then it also contains an edge $y \rightarrow z$ and/or an edge $z \rightarrow y$. You are given an undirected graph with $N$ vertices (numbered $1$ through $N$) and $M$ edges (numbered $1$ through $M$). Find a

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