report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Restricted path - MarisaOJ: Marisa Online Judge

Restricted path

Time limit: 1000 ms
Memory limit: 256 MB
Given an $n \times n$ grid, there are $q$ queries. Each query is of the form $(x, y)$, where $x \le y$. Starting from cell $(x, y)$, you can move from cell $(i,j)$ to cells $(i + 1, k)$ and $j \le k \le n$. However, you cannot move to cells with coordinates $(a, b)$ where $a > b$. Determine the number of ways to reach $(n, n)$ from $(x, y)$. ### Input - The first line contains two integers $n, q$. - The next $q$ lines, each containing two integers $x, y$, representing a query. ### Output - For each query, print an integer representing the number of paths modulo $998244353$ from $(x, y)$ to $(n, n)$. ### Constraints - $1 \le n,q \le 10^5$. - $1 \le x \le y \le n$. ### Sample test Input ``` 5 3 2 4 1 1 1 3 ``` Output: ``` 3 14 9 ```
Introduction to combinatorics
Binomial coefficient
Fork and knife
Binomial coefficient 2
Equation
Array rearrangement
Value of subsequences
Inequation
Growing mushrooms
Binary matrix
Broken board
Triangles counting
Minecraft graph
Restricted path
Heavenly Peach Garden
Topic
Combinatorics
Rating 1900
Solution (0) Solution