CF35C.Fire Again
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:64MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
After a terrifying forest fire in Berland a forest rebirth program was carried out. Due to it N rows with M trees each were planted and the rows were so neat that one could map it on a system of coordinates so that the j-th tree in the i-th row would have the coordinates of (i, j). However a terrible thing happened and the young forest caught fire. Now we must find the coordinates of the tree that will catch fire last to plan evacuation.
The burning began in K points simultaneously, which means that initially K trees started to burn. Every minute the fire gets from the burning trees to the ones that aren’t burning and that the distance from them to the nearest burning tree equals to 1.
Find the tree that will be the last to start burning. If there are several such trees, output any.
在贝尔兰发生了一场可怕的森林火灾后,当地实施了一项森林再生计划。根据该计划,共种植了 N 行树,每行 M 棵,且排列极为整齐,可将其映射到坐标系中,使得第 i 行的第 j 棵树的坐标为 (i,j)。然而,一场灾难发生了——这片年轻的森林再次起火。现在我们必须找出最后开始燃烧的那棵树的坐标,以便规划人员撤离。
火灾同时从 K 个点开始,即初始时刻共有 K 棵树着火。此后,每一分钟,火焰都会从已着火的树蔓延至尚未着火、且到最近着火树的距离恰好为 1 的树。
请找出最后开始燃烧的那棵树。若存在多个满足条件的树,输出任意一个即可。
输入格式
The first input line contains two integers N, M (1 ≤ N, M ≤ 2000) — the size of the forest. The trees were planted in all points of the (x, y) (1 ≤ x ≤ N, 1 ≤ y ≤ M) type, x and y are integers.
The second line contains an integer K (1 ≤ K ≤ 10) — amount of trees, burning in the beginning.
The third line contains K pairs of integers: _x_1, _y_1, _x_2, _y_2, ..., x__k, y__k (1 ≤ x__i ≤ N, 1 ≤ y__i ≤ M) — coordinates of the points from which the fire started. It is guaranteed that no two points coincide.
第一行输入包含两个整数 N、M(1≤N,M≤2000)——森林的尺寸。树木种植在所有形如 (x,y) 的点上(其中 1≤x≤N,1≤y≤M),且 x 和 y 均为整数。
第二行输入包含一个整数 K(1≤K≤10)——初始着火的树木数量。
第三行输入包含 K 对整数:x1, y1, x2, y2, …, xK, yK(其中 1≤xi≤N,1≤yi≤M)——火灾起始点的坐标。保证任意两点互不重合。
输出格式
Output a line with two space-separated integers x and y — coordinates of the tree that will be the last one to start burning. If there are several such trees, output any.
输出一行,包含两个用空格分隔的整数 x 和 y —— 表示最后开始燃烧的树的坐标。如果存在多个满足条件的树,输出任意一个即可。
输入输出样例
输入#1
3 3 1 2 2
输出#1
1 1
输入#2
3 3 1 1 1
输出#2
3 3
输入#3
3 3 2 1 1 3 3
输出#3
2 2
输入解题思路,AI测评打分。不知道怎么写?