#P6692. 出生点
出生点
Description
The map of this game can be abstracted as a grid with rows and columns. There are obstacle cells on the grid, and the edge length between two adjacent cells is . When the game starts, Little L Little W and Little H will each randomly spawn at a cell. Of course, they will not spawn on obstacle cells.
Little L, who often dies at the start, watches the paths that Little W and Little H take to meet up each time, and wants to know the expected distance between them after they spawn each time. (Here, the distance means the Manhattan distance between two points, i.e., .)
Since Little L can easily compute how many spawn arrangements there are, you actually only need to tell him the sum of the distances between them over all cases.
Note: The case where Little W spawns at point and Little H spawns at point , and the case where Little W spawns at point and Little H spawns at point , are considered the same case.
Input Format
The first line contains three integers , representing the number of rows, the number of columns, and the number of obstacle cells.
The next lines each contain two positive integers , representing the position of the -th obstacle.
Output Format
Output one integer, representing the sum of the distances between Little W and Little H’s spawn points over all cases.
Since Little L is extremely bored, he asks you to output the answer modulo .
3 3 2
2 1
3 3
42
9 8 8
3 2
4 6
7 3
9 5
3 7
2 2
1 6
6 4
11552
Hint
For sample 1, the map looks like this (blue points are obstacles, red points are possible spawn points):

- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
- Spawn points are and , distance is .
The total sum is .
Constraints
This problem uses bundled testdata.
- Subtask 1 ( ): .
- Subtask 2 ( ): .
- Subtask 3 ( ): .
- Subtask 4 ( ): .
- Subtask 5 ( ): no special restrictions.
For of the data, $1\leq n,m\leq 10^9,1\leq x_i\leq n,1\leq y_i\leq m,0\leq k\leq 5\times 10^5,k<n\times m$, and it is guaranteed that all obstacle cells are distinct.
Translated by ChatGPT 5
京公网安备 11011102002149号