Data Structures & AlgorithmsHardCodeforces Div 2 C · GATE CS
Grid with 3 rows and 3 columns (top to bottom). A cell marked G is a gate; '.' is a normal cell: ... ..G GG. Each step, which is a move to an adjacent cell or waiting one unit in place, takes exactly 1 time unit. A gate may only be occupied at an even time (t = 0, 2, 4, …); normal cells can be occupied at any time. You start at the top-left cell at time 0. What is the earliest time you can stand on the bottom-right cell?
- A. 5
- B. 6
- C. 4
- D. 7
Correct answer: A. 5
A BFS over (cell, time) states gives 5, since waiting is allowed and gates block odd arrival times. Ignoring gates gives 4, and forbidding waiting gives no answer.
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 grid has 6 rows and 5 columns (top to bottom; '.' open, '#' blocked): ...#. .#..# ..... ##.#. ..... ..... You may only move right or…
- An undirected connected graph on 5 vertices has the edges (weights in brackets, all distinct): V–H (5), V–D (15), V–X (10), X–D (26), V–Z…
- Each cell of a grid with 5 rows and 3 columns has an arrow: R = right, L = left, U = up, D = down. ULR UUD ULL LUL UDU From a cell you may…
- 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…
- 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…