编程介的小学生 2017-02-10 04:43 采纳率: 20.5%
浏览 876
已采纳

Coffee Central

问题描述 :

Is it just a fad or is it here to stay? You’re not sure, but the steadily increasing number of coffee shops that are opening in your hometown has certainly become quite a draw. Apparently, people have become so addicted to coffee that apartments that are close to many coffee shops will actually fetch higher rents.

This has come to the attention of a local real-estate company. They are interested in identifying the most valuable locations in the city in terms of their proximity to large numbers of coffee shops. They have given you a map of the city, marked with the locations of coffee shops. Assuming that the average person is willing to walk only a fixed number of blocks for their morning coffee, you have to find the location from which one can reach the largest number
of coffee shops. As you are probably aware, your hometown is built on a square grid layout, with blocks aligned on north-south and east-west axes. Since you have to walk along streets, the distance between intersections (a, b) and (c, d) is |a – c| + |b – d|.

输入:

The input contains several test cases. Each test case describes a city. The first line of each test case contains four integers dx, dy, n, and q. These are the dimensions of the city grid dx × dy (1 <= dx, dy <= 1000), the number of coffee shops n (0 <= n <= 5 × 10^5), and the number of queries q (1 <= q <= 20). Each of the next n lines contains two integers xi and yi (1 <= xi <= dx, 1 <= yi <= dy); these specify the location of the ith coffee shop. There will be at most one coffee shop per intersection. Each of the next q lines contains a single integer m (0 <= m <= 10^6), the maximal distance that a person is willing to walk for a cup of coffee.
The last test case is followed by a line containing four zeros.

输出:

The input contains several test cases. Each test case describes a city. The first line of each test case contains four integers dx, dy, n, and q. These are the dimensions of the city grid dx × dy (1 <= dx, dy <= 1000), the number of coffee shops n (0 <= n <= 5 × 10^5), and the number of queries q (1 <= q <= 20). Each of the next n lines contains two integers xi and yi (1 <= xi <= dx, 1 <= yi <= dy); these specify the location of the ith coffee shop. There will be at most one coffee shop per intersection. Each of the next q lines contains a single integer m (0 <= m <= 10^6), the maximal distance that a person is willing to walk for a cup of coffee.
The last test case is followed by a line containing four zeros.

样例输入:
4 4 5 3
1 1
1 2
3 3
4 4
2 4
1
2
4
0 0 0 0

样例输出:
Case 1:
3 (3,4)
4 (2,2)
5 (3,1)

  • 写回答

2条回答 默认 最新

  • devmiao 2017-02-13 18:10
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler