Data Structures & AlgorithmsHardCodeforces Div 2 D · ICPC regional
A directed graph has the vertices D, E, H, I, K, N, O and the arcs N→E, N→D, K→N, K→O, E→O, I→N, I→E, H→K, O→N. How many strongly connected components does it have (maximal sets in which every vertex can reach every other)?
- A. 1
- B. 6
- C. 5
- D. 2
Correct answer: C. 5
Mutual reachability splits the vertices into 5 classes, each a strongly connected component (single vertices count too). Weakly connected components give 1, and counting only components with at least two vertices gives 1.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- A tree has the vertices A, C, M, R, V, Y, Z and the edges C–M, M–A, C–R, A–Y, A–V, R–Z. A set D dominates the tree if every vertex is in D…
- A directed graph with no directed cycles has arcs u→v (weight) : F→S (3), F→N (0), F→C (8), G→X (2), G→C (4), S→X (3), N→X (1), N→C (6)…
- A connected undirected graph has the vertices B, E, G, K, Q, R, S, V and the edges Q–K, K–B, K–G, K–S, G–V, G–R, G–E, S–E, R–E. Parallel…
- Grid with 4 rows and 3 columns (top to bottom). A cell marked G is a gate; '.' is a normal cell: .GG G.G .G. ... Each step, which is a…
- A tree has vertices with values in brackets: P[-4], S[4], V[7], U[1], G[-4], D[1]. The edges are P–S, S–V, V–U, S–G, S–D. A path is any…
- A four-wheel combination lock shows four digits 0–9 on wheels that wrap around (9 goes to 0 and 0 goes to 9). One move turns one wheel by…