luogu#P10807. [LMXOI Round 2] Disaster
[LMXOI Round 2] Disaster
Background
LMX and HQZ are studying how to partition points.
Problem Description
Given points, each point provides a pair of constraints . A partition is defined to be good if and only if, for every point , after partitioning, both and are not in the same interval as . Find the number of good partitions. Output the answer modulo .
Supplement: In this problem, a partition means dividing the points into several intervals such that each point belongs to exactly one interval. and can be considered as no constraint.
Input Format
The first line contains an integer , which represents the number of points.
The next lines each contain two integers on the -th line.
Output Format
Output one integer on the first line, which is the answer modulo .
5
0 3
0 3
1 6
2 6
2 6
8
Hint
Sample Explanation #1
The legal interval partitions in the sample are:
For all testdata, , .
| Subtask ID | Special Property | Score | |
|---|---|---|---|
| Subtask #1 | None | ||
| Subtask #2 | |||
| Subtask #3 | |||
| Subtask #4 | |||
| Subtask #5 | None | ||
| Subtask #6 |
Translated by ChatGPT 5