#P15129. [ROIR 2026] 筹码放置
[ROIR 2026] 筹码放置
Problem Description
You are given a square board of size . The rows and columns of the board are numbered from to .
You need to place chips on the board so that each cell contains at most one chip. At the same time, you must satisfy constraints. The -th constraint gives two integers and , meaning that in the rectangular area with coordinates , at most one chip can be placed.
Compute the number of different chip placement schemes that satisfy all constraints, and output the result modulo .
Input Format
The first line of the input contains two integers and — the number of constraints and the size of the board (, ).
The next lines each contain two numbers and ().
Output Format
Output one number — the number of valid chip placement schemes modulo .
1 4
4 4
17
2 2
1 2
2 1
10
3 5
2 5
3 4
4 4
4480
Hint
Sample Explanation
In the first sample, at most one chip can be placed on the entire board. There are ways to place one chip, and way to place no chips.
Scoring Rules
| Subtask | Points | Additional Constraints | Required Subtasks |
|---|---|---|---|
| 1 | 3 | --- | |
| 2 | 6 | ||
| 3 | 8 | 1, 2 | |
| 4 | 1–3 | ||
| 5 | 10 | 1 | |
| 6 | 1, 5 | ||
| 7 | 1–3, 5, 6 | ||
| 8 | 1–3, 5–7 | ||
| 9 | 15 | 1–3, 5–8 | |
| 10 | 20 | No additional constraints | 1–9 |
Translated by DeepSeek.
Translated by ChatGPT 5