#P7436. 画矩形
画矩形
Description
The lord of Shandianbei Palace drew an rectangular grid. Specifically, it contains all integer points with coordinates (), and all edges connecting pairs of points with distance .
Now they want to know how many rectangles with perimeter not greater than can be drawn inside this grid (all four sides of the rectangle must be parallel to the coordinate axes). But even as an easy warm-up problem, this would still be too simple, so they added obstacle points and require that the chosen rectangle does not contain any obstacle point. Each obstacle point is a square. Now the lord of Shandianbei Palace is going to make other “easy (tricky)” problems, can you help solve this one? Output the answer modulo .
Input Format
The first line contains four positive integers , , , and .
The next lines each contain two numbers, the coordinate and the coordinate of an obstacle (an obstacle at coordinate has four vertices ).
Output Format
Output one line with one integer, the number of rectangles modulo .
3 3 4 4
1 1
2 2
3 3
2 3
5
3 3 4 10000
1 1
2 2
3 3
2 3
8
Hint
Sample Explanation
Sample #1: All cells except the obstacle cells are valid rectangles. Therefore, the answer is .
Sample #2: This is just counting the number of valid rectangles. There are rectangles of size , and rectangles in total of sizes and , so the answer is .
Constraints
| ID | |||
|---|---|---|---|
For of the testdata, , , . It is guaranteed that all obstacles are valid and pairwise distinct.
Translated by ChatGPT 5
京公网安备 11011102002149号