Data Structures & AlgorithmsHardCodeforces Div 2 D · ICPC regional
A directed graph has the vertices A, E, F, M, N, R and the arcs R→F, R→M, A→M, M→R, M→A, E→F, E→N. How many strongly connected components does it have (maximal sets in which every vertex can reach every other)?
- A. 3
- B. 1
- C. 5
- D. 4
Correct answer: D. 4
Mutual reachability splits the vertices into 4 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
- Floyd–Warshall runs on vertices 1 to 4 with these arcs u→v (weight): 1→2 (1), 1→3 (11), 1→4 (12), 2→1 (12), 2→3 (2), 2→4 (8), 3→1 (7), 3→2…
- Two unmarked jugs hold 6 litres and 8 litres. Allowed operations: fill a jug completely, empty a jug completely, or pour one jug into the…
- 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…
- A tree has the vertices B, E, H, I, Q, R, U, V and the edges V–I, I–H, H–R, H–U, R–B, I–E, U–Q. A centroid is a vertex whose removal…
- A tree on the vertices B, C, D, H, J, T, Z has the arcs T→B, Z→T, B→C, B→D, J→D, J→H (each undirected edge is directed as shown). You may…
- A grid has 4 rows and 4 columns with these values (top to bottom): 9446 8699 5398 3165 A path moves between side-adjacent cells (up, down…