编程介的小学生 2017-04-16 15:01 采纳率: 20.5%
浏览 737
已采纳

Safest Points

Himekaidou Hatate (姫海棠はたて) is a crow tengu with the ability of spirit photography. The newspaper she writes, Kakashi Spirit News (「花果子念報」) is much less popular than Shameimaru Aya's Bunbunmaru News (「文々。新聞」). In order to beat Aya, Hatate decides to report Toramaru Shou, the disciple of Bishamonten (多闻天王). But it's not easy to take pictures of Shou and her bullet patterns while avoiding them as well.

Assum that both Hatate and Shou stay in a w*h grid region. Shou fire lasers out in straight lines, the i-th laser starts at (xi, yi) and moves in direction (dxi, dyi). The Manhattan distance of any two points (x1, y1) and (x2, y2) is |x1 - x2| + |y1 - y2|. Any point with a Manhattan distance to some laser that is less that 1 is called dangerous point. All other points are safe points. The points which have maximum Manhattan distance to dangerous points is called safest points. Hatate hopes that a new feature can be added to her camera - for each senario, finding out the safest points quickly. You're asked to develop this feature.

Input

There are multiple cases. Each one describes a senario. The first line is "w h n", where 3 ≤ w, h ≤ 1000 and 1 ≤ n ≤ 1000 is the number of lasers. The i+1-th line is the i-th laser "xi yi dxi dyi", where 0 ≤ xi < w, 0 ≤ yi < h, dxi2 + dyi2 > 0. Process to the each of file.

Output

For each case, output all safest points seperated by a single blank in lexicographic order. If there are no safe points, output "MISS!" instead.

Sample Input

3 3 3
0 0 2 1
0 1 2 1
0 2 2 -2
4 4 2
0 0 3 3
3 0 -1 1
5 5 2
4 4 -1 -1
0 4 2 -2
Sample Output

MISS!
(0, 1) (0, 2) (1, 0) (1, 3) (2, 0) (2, 3) (3, 1) (3, 2)
(0, 2) (2, 0) (2, 4) (4, 2)

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-05-01 01:15
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛