Data Structures & AlgorithmsModerateCodeforces Div 2 · ICPC regional

5 × 5 grid, rows top to bottom ('#' = blocked, '.' = open): ..... / ..#.. / ..... / ..#.. / #..... Count the paths from top-left to bottom-right that move only RIGHT or DOWN and never enter a blocked cell. How many such paths exist?

  1. A. 25
  2. B. 18
  3. C. 22
  4. D. 19

Correct answer: B. 18

Counting right/down paths with DP gives 18; blocked cells contribute zero paths. Counting open cells instead of paths is a confusion of the two.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic