Data Structures & AlgorithmsHardCodeforces Div 2 D · ICPC regional
A grid has 3 rows and 4 columns with these values (top to bottom): 1912 3838 7521 A path moves between side-adjacent cells (up, down, left or right) and each next cell must have a strictly larger value than the current cell. What is the largest number of cells on such a path?
- A. 5
- B. 4
- C. 3
- D. 6
Correct answer: A. 5
A memoised DFS from every start gives 5 cells. Restricting moves to right and down gives 3, and allowing equal values (non-decreasing paths) gives 3.
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 directed graph with no directed cycles has arcs u→v (weight) : K→Q (2), K→N (-3), K→I (8), J→L (3), J→I (8), Q→N (7), Q→L (6), N→L (0)…
- A directed graph has the vertices A, D, J, N, P, V and the arcs N→V, N→P, N→A, V→A, D→A, P→A, A→V, A→D, A→J. How many strongly connected…
- Bellman–Ford is run from source M on the directed graph whose arcs (weights in brackets) are listed in the order they are relaxed: G→D…
- A grid has 5 rows and 6 columns (top to bottom; '.' open, '#' blocked): ...... .##.#. ...... ....#. ...... You may only move right or…
- A tree has the vertices B, D, E, G, J, O, S, W and the edges S–J, J–D, J–B, B–O, S–G, D–W, G–E. A set D dominates the tree if every vertex…
- 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…