当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3702:The Covering Polygon

题目描述
Martians are invading the earth! Yes, it's not an illusion, it's the truth. Their attack are so quickly and unpredictable that few people realize it until many most buildings are destroyed. As a human being on the earth, you feel it's your duty to protect your homeland.

After scouting, you find there are some powerful weapons which are still working well on the land. They are the last hope to defeat the Martains, so all of them should be protected. And there are a few of defensive devices can be used. If you activate these devices in the order D1, D2, .., Dn, then there will be a laser line between D1 and D2, D2 and D3, ..., Dn and D1, which forms a polygon. Everything enclosed by the polygon or laid on the boundary can be protected well. Due to some physical reasons, nonadjacent laser lines can not intersect (even intersect at end points), or they will disappear and leave a hole in the polygon, which Martains can go through to destroy everything. Of course, no devices can be activated two or more times.

The final wave of Martains is near, so you need design a plan to construct our defence quickly. Activating a defensive device is very hard and time-consuming, so you should active as few as possible to protect all the weapons. You have the ability, and you have the duty, too.
输入解释
The beginning of the input is an integer T (T <= 30), which is the number of test cases. T cases are followed. The first line of each test case is two integers sizeA (3 <= sizeA <= 500) and sizeB (3 <= sizeB <= 200000), which denote the number of defensive devices and the number of weapons respectively. Each of them can be considered as a point in 2D euclid plane. The next sizeA+sizeB lines are positions of devices and weapons, each of which contains two integers describing its x and y coordinates. The first sizeA lines are points of defensive devices, and the last sizeB lines are points of weapons.

The absolute value of all coordinates are not greater than 10^8. Positions of any two objects in the same test case are distinct. Because of some strange reasons, not all of the weapons are on the same line.
输出解释
For each test case, print a line contains a single integer which is the least devices to be actived to protect all weapons. If all weapons can not be protected, output -1 instead.
输入样例
2

4 3
1 1
2 2
3 3
4 4
5 5
6 6
7 9

7 3
0 5
5 0
-5 0
100 100
-100 -100
100 -100
-100 100
0 0
0 1
1 1
输出样例
-1
3
来自杭电HDUOJ的附加信息
Author wywcgs @ HIT & XMU
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3702

最后修改于 2020-10-25T23:06:12+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
20000/15000MS(Java/Others) 32768/32768K(Java/Others)