Skip to main content

Practice · 3 of 3

Grid Paths Around the Wall

CHALLENGE
Difficulty: advanced+25 XP

**Problem.** Line 1: q. Each line: n m then bx by (the forbidden cell). Print paths from (0,0) to (n,m) moving only +x/+y, avoiding the forbidden cell, mod 1e9+7. **Constraints:** 1 ≤ q ≤ 200000; 0 ≤ n, m ≤ 10^6; cell may lie outside. Two binomials per query; the unreduced-subtraction W overflows.

Back to lesson: Practice: Counting Suite