#P6559. [SBCOI2020] 小镇
[SBCOI2020] 小镇
Description
The town can be viewed as an grid, where cells are houses.
There are also lamps in the town. Between every two adjacent cells, there is a lamp.
If two houses are adjacent, then the lamp between these two houses will be lit.
Please find how many lamps are lit in total in this town.
Note: in this problem, “adjacent” means sharing a common edge.
Input Format
The first line contains two integers , representing the side length of the grid and the number of houses.
The next lines each contain two integers , representing the coordinates of a house.
Output Format
One line with one integer, representing the answer.
6 12
1 1
2 1
2 2
1 4
3 3
4 3
4 4
3 4
3 6
4 6
5 6
6 6
9
Hint
Sample Explanation

As shown in the figure, the shaded cells are houses, and the red edges are lamps.
Constraints
For of the testdata, .
For of the testdata, .
For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号