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

建议使用的浏览器:

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

1959:Watchdog

题目描述
A company (name withheld) has an office building in the center of Lund. The building has a perfectly square roof with a number of hatches. Because of a series of burglaries where the perpetrators have entered through these hatches, it was decided to use a watchdog to guard the hatches. A particularly vicious but rather stupid breed of dog was chosen, and unfortunately the dog fell off the roof on its third watch.

A new dog has been procured and it has been decided to attach a leash to its collar and attach the other end at some point on the roof. However, if the leash is too short the dog cannot reach all hatches, but if it is too long then the dog will fall off the building again. The leash has hooks at both ends, so no part of it is used to tie knots. The company wants the dog to reach the center of each hatch (the dog can reach exactly as far as the leash could reach if it were lying flat on the roof), but it does not want the leash to extend beyond the edge of the roof (to the edge is OK). They hope that by carefully choosing the length of the leash and where to attach it, the dog will be able to reach all hatches without risking falling off the building. A leash can only be attached at a point with integer coordinates (if the building is 10 by 10 meters, then the south-west corner of the building has coordinates (0, 0) and the north-east corner has coordinates (10, 10)). A leash cannot be attached at a point where there is a hatch.

If there is no place where you can attach a leash, reach all hatches but not reach beyond the edge of the roof, it is impossible to use this breed of dog, and the company will instead use a poodle (which is a less vicious type of dog, but also less prone to falling off buildings).
输入解释
On the first line of the input is a single positive integer N, telling the number of test cases to follow. Each case starts with one line with two integers S H, where S is even, 2 <= S <= 40, and 1 <= H <= 50. S is the side of the square roof in meters and H is the number of hatches. The following H lines each contain two integers X and Y. These are the coordinates of the hatches. Hatches will never lie outside the roof or on the roof’s perimeter. No two hatches will occupy the same position
输出解释
For each test case, output one line containing the coordinates X Y at which to fasten the leash (if there are several possible points, output the one with smallest X, and if there are still several possibilities select the one with smallest Y among those with smallest X) such that a leash of suitable length allows access to all hatches without extending beyond the edge of the roof. If there is no such point, output “poodle” for that test case.
输入样例
3
10 2
6 6
5 4
20 2
1 1
19 19
10 3
1 1
1 2
1 3
输出样例
3 6
poodle
2 2
来自杭电HDUOJ的附加信息
Recommend wangye

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

题目来源 NWERC2004

源链接: HDU-1959

最后修改于 2020-10-25T22:49:17+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
5000/1000MS(Java/Others) 65536/32768K(Java/Others)