bzoj#P1741. [Usaco2005 nov]Asteroids 穿越小行星群
[Usaco2005 nov]Asteroids 穿越小行星群
题目描述
Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an grid . The grid contains asteroids , which are conveniently located at the lattice points of the grid. Fortunately, Bessie has a powerful weapon that can vaporize all the asteroids in any given row or column of the grid with a single shot. This weapon is quite expensive, so she wishes to use it sparingly. Given the location of all the asteroids in the field, find the minimum number of shots Bessie needs to fire to eliminate all of the asteroids.
贝茜想驾驶她的飞船穿过危险的小行星群。小行星群是一个 的网格,在网格内有 个小行星。幸运地是贝茜有一个很强大的武器,一次可以消除所有在一行或一列中的小行星,这种武器很贵,所以她希望尽量地少用。给出所有的小行星的位置,算出贝茜最少需要多少次射击就能消除所有的小行星。
输入格式
- Line : Two integers and , separated by a single space.
- Lines : Each line contains two space-separated integers and denoting the row and column coordinates of an asteroid, respectively.
- 第一行:两个整数 和 ,用一个空格隔开。
- 第二行至 行:每一行有两个空格隔开的整数 ,分别表示小行星所在的行和列。
输出格式
- Line : The integer representing the minimum number of times Bessie must shoot.
- 一个整数表示贝茜需要的最少射击次数,可以消除所有的小行星。
3 4
1 1
1 3
2 2
3 2
2
样例说明
INPUT DETAILS:
The following diagram represents the data, where X
is an asteroid and .
is empty space:
X.X
.X.
.X.
OUTPUT DETAILS:
Bessie may fire across row to destroy the asteroids at and, and then she may fire down column to destroy the asteroids at and .
数据规模与约定
对于 的数据,,,。
题目来源
Gold