#P7368. [USACO05NOV] Asteroids G
[USACO05NOV] Asteroids G
Description
Bessie wants to fly her spaceship in an grid. There are asteroids in the grid. To make the flight enjoyable, she must remove all of these asteroids.
Bessie has a weapon that can remove all asteroids in one row or one column at a cost of one unit. Bessie wants to know the minimum cost to remove all asteroids.
Input Format
The first line contains two integers .
The next lines each contain , representing the coordinates of the -th asteroid in the grid.
Output Format
Output one integer per line, representing the minimum cost to remove all asteroids.
3 4
1 1
1 3
2 2
3 2
2
Hint
Sample Explanation:
The sample grid is (where X represents an asteroid):
X.X
.X.
.X.
Bessie can remove the asteroids by removing the first row and the second column.
Constraints:
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号