Data Structures & AlgorithmsVery hardICPC regional · Codeforces Div2 D
Problem: A directed flow network has source s = 0 and sink t = 3 with arcs and capacities: 0→1 (3), 0→2 (2), 1→2 (1), 1→3 (2), 2→3 (3). What is the maximum flow from 0 to 3?
- A. 5
- B. 6
- C. 4
- D. 7
Correct answer: A. 5
Edmonds–Karp augments along shortest residual paths until no path to the sink remains; the total pushed is the max flow, which equals the min cut. Greedily saturating the first path found can stop short.
More Coding Interview Problems questions
- Problem: A bottleneck path from vertex 0 to vertex 4 minimises the largest edge weight used. Using the undirected edges 0-1 (7), 1-2 (3)…
- Problem: A DAG has 4 vertices with edges 0→2 and 1→2 and 2→3 (vertices 0, 1 have no incoming arcs). How many distinct topological orders…
- Problem: In the undirected graph on vertices 0–4 with edges 0-1, 0-2, 1-2, 1-3, 2-3, 3-4, how many Hamiltonian paths exist (paths that…
- Problem: On a rooted tree (root 1) with children: 1: [2, 3], 2: [4, 5, 6], 3: [7], 5: [8, 9]. How many nodes have exactly 2 descendants…
- Problem: A binary tree is encoded in preorder with '#' for a missing child: "1,2,#,#,3,4,#,#,5,#,#". How many leaves (nodes with two…
- Problem: Count the palindromic substrings of length exactly 4 in the string "aabbaabbaa".