Codeforces Beta Round 35(Div. 2)
C
再次起火
Fire Again
Codeforces
1500
原题
← BD →

再次起火AI (CI翻译)

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.

翻译中…

Input

输入格式

AI (CI翻译)

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.

第一行包含两个整数 $*N*$、$*M*$($1 ≤ *N*$、$*M*$ ≤ 2000),表示森林的大小。树种植在所有形如($*x*$,$*y*$)的点上,其中 $1 ≤ *x*$ ≤ N$,$1 ≤ y$ ≤ *M*$,且 $*x*$ 和 $*y*$ 均为整数。AI (CI翻译)

The second line contains an integer $*K*$ ($1 ≤ *K* ≤ 10$) — amount of trees, burning in the beginning.

第二行包含一个整数 $*K*$($1 ≤ *K*$ ≤ 10),表示最初燃烧的树的数量。AI (CI翻译)

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.

第三行包含 $*K*$ 对整数:$*x*_{1}$、$*y*_{1}$、$*x*_{2}$、$*y*_{2}$、...、$*x*_{*k*}$、$*y*_{*k*}$($1 ≤ *x*_{*i*}$ ≤ N$,$1 ≤ y_{i}$ ≤ *M*$),表示火灾开始的点的坐标。保证不存在两个坐标相同的点。AI (CI翻译)

Output

输出格式

AI (CI翻译)

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*$,表示最后开始燃烧的树的坐标。如果有多棵这样的树,输出其中任意一棵。AI (CI翻译)

样例

Input #1
3 3
1
2 2
Output #1
1 1
InputCopy OutputCopy
Input #2
3 3
1
1 1
Output #2
3 3
InputCopy OutputCopy
Input #3
3 3
2
1 1 3 3
Output #3
2 2
InputCopy OutputCopy
题目信息
题号
35C
时间限制
2 s
内存限制
64 MB
标签
暴力
DFS 及类似
最短路

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。