#P12148. 【MX-X11-T2】「蓬莱人形 Round 1」所以我放弃了音乐
【MX-X11-T2】「蓬莱人形 Round 1」所以我放弃了音乐
Description
On an infinite chessboard, there are distinct pieces at positions . You must delete all pieces by performing the following operation multiple times:
- Choose a grid .
- If there is a piece at , delete it. Otherwise, end the current operation.
- Sequentially check the grids at , , and . Upon finding the first grid with a piece, stop checking, update to this grid's coordinates, and return to Step 2. If none of these grids contain a piece, end the current operation.
Determine the minimum number of operations required to delete all pieces.
Input Format
The first line contains a positive integer indicating the number of pieces.
The next lines each contain two positive integers , representing the coordinates of a piece. All positions are guaranteed to be distinct.
Output Format
Output a single positive integer representing the minimum number of operations needed.
4
1 3
2 2
3 1
3 3
2
9
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
3
Hint
Explanation #1
For the first sample, the chessboard is shown below:

- First operation: Choose . This deletes the pieces at , , and .
- Second operation: Choose . This deletes the piece at .
It can be proven that no better strategy exists.
Constraints
This problem uses subtask scoring.
For all test data: , .
| Subtask | Special Property | Points | ||
|---|---|---|---|---|
| 1 | A | 10 | ||
| 2 | None | 20 | ||
| 3 | ||||
| 4 | ||||
| 5 | 30 | |||
- Special Property A: All are equal.
Translated by DeepSeek R1
京公网安备 11011102002149号