#P5816. [CQOI2010] 内部白点
[CQOI2010] 内部白点
Description
On an infinite square grid, there are black vertices, and all other vertices are white (grid vertices are points with integer coordinates, also called lattice points). Every second, all internal white points turn black simultaneously, until there are no internal white points left. Your task is to count the number of black points in the grid at the end.
Definition of an internal white point: a white lattice point is an internal white point if and only if there is at least one black point to the left and to the right of on the same horizontal line (i.e., there exist such that and are both black), and at least one black point above and below on the same vertical line (i.e., there exist such that and are both black).
Input Format
The first line contains an integer , the number of initial black points.
The next lines each contain two integers , , the coordinates of a black point. No two black points have the same coordinates, and the absolute value of each coordinate does not exceed .
Output Format
Output one line containing the final number of black points.
If the recoloring process never terminates, output -1.
4
0 2
2 0
-2 0
0 -2
5
Hint
Constraints
For of the testdata, .
For of the testdata, .
For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号