Skip to main content

Final Simulation: The Detour

Challenge on lesson: Final Simulation — Full Contest Stack

CHALLENGE
Difficulty: advanced+25 XP

**Bài toán.** Count paths from the top-left cell (1,1) to the bottom-right cell (n,n) of an n×n grid, moving only right or down, never stepping on a blocked cell. Count modulo 10^9 + 7. **Constraints:** 2 ≤ n ≤ 2000; 0 ≤ b ≤ 2000 blocked cells; blocked cells never include (1,1) or (n,n). **Input:** line 1: n, b; then b lines: r, c (row, then column — 1-based). **Output:** one integer — the number of paths modulo 10^9 + 7.

Back to lesson: Final Simulation — Full Contest Stack