CF491B.New York Hotel

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

将纽约视为一个矩形网格,包含 NN 条纵向大道(编号从 11 到 NN)和 MM 条横向街道(编号从 11 到 MM)。CC 位朋友住在位于某些街-道交叉口的 CC 家酒店中。他们计划在 HH 家餐厅(同样位于某些街-道交叉口)中的某一家为其中一位朋友庆祝生日。他们还希望所有人前往该餐厅途中,单人所行距离的最大值尽可能小。请帮助这些朋友选择最优的庆祝餐厅。

假设相邻交叉口之间的距离均相等,为一公里。

输入格式

The first line contains two integers N и M — size of the city (1 ≤ N, M ≤ 109). In the next line there is a single integer C (1 ≤ C ≤ 105) — 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 ≤ 105). Following H lines contain descriptions of restaurants in the same format.

Several restaurants and hotels may be located near the same crossing.

第一行包含两个整数 NN 和 MM —— 城市的尺寸(1 ≤ N, M ≤ 1091 \leq N, M \leq 10^9)。
第二行包含一个整数 CC(1 ≤ C ≤ 1051 \leq C \leq 10^5)—— 朋友们入住的酒店数量。
接下来的 CC 行描述了这些酒店,每行包含两个坐标 xx 和 yy(1 ≤ x ≤ N1 \leq x \leq N, 1 ≤ y ≤ M1 \leq y \leq M)。
下一行包含一个整数 HH —— 餐厅的数量(1 ≤ H ≤ 1051 \leq H \leq 10^5)。
接下来的 HH 行以相同格式描述了这些餐厅。

多个餐厅和酒店可能位于同一个路口附近。

输出格式

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

输入解题思路,AI测评打分。不知道怎么写?

首页