Data Structures & AlgorithmsVery hardICPC regional · Codeforces Div2 D

Problem: A directed graph on vertices 0–5 has arcs 0→1, 1→2, 2→0, 2→3, 3→4, 4→3, 4→5. Its strongly connected components are computed. How many components contain more than one vertex?

  1. A. 3
  2. B. 2
  3. C. 1
  4. D. 4

Correct answer: B. 2

Two vertices share a strongly connected component when each reaches the other. Grouping by reachability in both directions finds the multi-vertex components; counting weakly connected pieces instead gives a different count.

More Coding Interview Problems questions

Exams that ask this topic