luogu#P9563. [SDCPC2023] Be Careful 2
[SDCPC2023] Be Careful 2
题目背景
警告:滥用本题评测将被封禁。
题目描述
Little Cyan Fish has an rectangle located in a plane. The top-right corner of the rectangle is at , while the bottom-left corner is at . There are banned points inside the rectangle. The -th banned point is located at .
Little Cyan Fish would like to draw a square inside the rectangle. However, he dislikes all the banned points, so there cannot be any banned points inside his square. Formally, Little Cyan Fish can draw a square with the bottom-left corner at and a side length if and only if:
- Both and are non-negative integers while is a positive integer.
- .
- .
- For each , the following condition must NOT be met:
- and .
Please calculate the sum of the areas of all the squares that Little Cyan Fish can possibly draw. Since the answer could be huge, you need to output it modulo .
输入格式
The is only one test case in each test file.
The first line of the input contains three integers , and (, ) indicating the size of the rectangle and the number of banned points.
For the following lines, the -th line contains two integers and (, ) indicating the position of the -th banned point. It is guaranteed that all the banned points are distinct.
输出格式
Output one line containing one integer indicating the answer modulo .
题目大意
【题目描述】
小青鱼有一个位于二维平面上的,大小为 的矩形。矩形的右上角位于 ,而左下角位于 。矩形内部有 个禁止点,第 个禁止点位于 。
小青鱼想在矩形里画一个正方形。但由于小青鱼不喜欢禁止点,因此正方形的内部不能有任何禁止点。更正式地,小青鱼可以画一个左下角位于 且边长为 的正方形,当且仅当:
- 和 都是非负整数, 是一个正整数。
- 。
- 。
- 每个 都 不能 满足以下条件:
- 且 。
请计算小青鱼可以画的正方形的总面积。由于答案可能很大,请将答案对 取模后输出。
【输入格式】
每个测试文件仅有一组测试数据。
第一行输入三个整数 , 和 (,),表示矩形的大小和禁止点的数量。
对于接下来 行,第 行输入两个整数 和 (,)表示第 个禁止点的位置。保证所有禁止点互不相同。
【输出格式】
输出一行一个整数,代表对 取模后的答案。
【样例解释】
对于第一组样例数据,小青鱼有 种方式画一个正方形,如下图所示。
共有 个边长为 的正方形和 个边长为 的正方形。因此答案为 。
以下画正方形的方式是不合法的,因为正方形内有一个禁止点。
3 3 1
2 2
21
5 5 2
2 1
2 4
126
提示
For the first sample test case, Little Cyan Fish has ways to draw a square, illustrated as follows.
There are squares of side length and squares of side length . So the answer is .
Note that the following plans are invalid since there's a banned point in the square.