302543: CF491B. New York Hotel
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
New York Hotel
题意翻译
将纽约视为N∗M的矩阵,单位长度为1。两点之间的距离是他们的曼哈顿距离。 现在有c个人各自住在c个酒店。他们要搞一个聚会。一共有h个餐厅可供选择,他们希望最远的人到餐厅的距离尽量小。题目描述
Think of New York as a rectangular grid consisting of $ N $ vertical avenues numerated from $ 1 $ to $ N $ and $ M $ horizontal streets numerated $ 1 $ to $ M $ . $ C $ friends are staying at $ C $ hotels located at some street-avenue crossings. They are going to celebrate birthday of one of them in the one of $ H $ restaurants also located at some street-avenue crossings. They also want that the maximum distance covered by one of them while traveling to the restaurant to be minimum possible. Help friends choose optimal restaurant for a celebration. Suppose that the distance between neighboring crossings are all the same equal to one kilometer.输入输出格式
输入格式
The first line contains two integers $ N $ и $ M $ — size of the city ( $ 1<=N,M<=10^{9} $ ). In the next line there is a single integer $ C $ ( $ 1<=C<=10^{5} $ ) — the number of hotels friends stayed at. Following $ C $ lines contain descriptions of hotels, each consisting of two coordinates $ x $ and $ y $ ( $ 1<=x<=N $ , $ 1<=y<=M $ ). The next line contains an integer $ H $ — the number of restaurants ( $ 1<=H<=10^{5} $ ). Following $ H $ lines contain descriptions of restaurants in the same format. Several restaurants and hotels may be located near the same crossing.
输出格式
In the first line output the optimal distance. In the next line output index of a restaurant that produces this optimal distance. If there are several possibilities, you are allowed to output any of them.
输入输出样例
输入样例 #1
10 10
2
1 1
3 3
2
1 10
4 4
输出样例 #1
6
2