Codeforces Round 671 (Div. 2)
F
Rain of Fire
Codeforces
2800
原题
← E→
翻译中…

There are $n$ detachments on the surface, numbered from $1$ to $n$, the $i$-th detachment is placed in a point with coordinates $(x_i, y_i)$. All detachments are placed in different points.

翻译中…

Brimstone should visit each detachment at least once. You can choose the detachment where Brimstone starts.

翻译中…

To move from one detachment to another he should first choose one of four directions of movement (up, right, left or down) and then start moving with the constant speed of one unit interval in a second until he comes to a detachment. After he reaches an arbitrary detachment, he can repeat the same process.

翻译中…

Each $t$ seconds an orbital strike covers the whole surface, so at that moment Brimstone should be in a point where some detachment is located. He can stay with any detachment as long as needed.

翻译中…

Brimstone is a good commander, that's why he can create at most one detachment and place it in any empty point with integer coordinates he wants before his trip. Keep in mind that Brimstone will need to visit this detachment, too.

翻译中…

Help Brimstone and find such minimal $t$ that it is possible to check each detachment. If there is no such $t$ report about it.

翻译中…

Input

翻译中…

The first line contains a single integer $n$ $(2 \le n \le 1000)$ — the number of detachments.

翻译中…

In each of the next $n$ lines there is a pair of integers $x_i$, $y_i$ $(|x_i|, |y_i| \le 10^9)$ — the coordinates of $i$-th detachment.

翻译中…

It is guaranteed that all points are different.

翻译中…

Output

翻译中…

Output such minimal integer $t$ that it is possible to check all the detachments adding at most one new detachment.

翻译中…

If there is no such $t$, print $-1$.

翻译中…

Note

翻译中…

In the first test it is possible to place a detachment in $(0, 0)$, so that it is possible to check all the detachments for $t = 100$. It can be proven that it is impossible to check all detachments for $t \lt 100$; thus the answer is $100$.

翻译中…

In the second test, there is no such $t$ that it is possible to check all detachments, even with adding at most one new detachment, so the answer is $-1$.

翻译中…

In the third test, it is possible to place a detachment in $(1, 0)$, so that Brimstone can check all the detachments for $t = 2$. It can be proven that it is the minimal such $t$.

翻译中…

In the fourth test, there is no need to add any detachments, because the answer will not get better ($t = 2$). It can be proven that it is the minimal such $t$.

翻译中…

样例

Input #1
4
100 0
0 100
-100 0
0 -100
Output #1
100
InputCopy OutputCopy
Input #2
7
0 2
1 0
-3 0
0 -2
-1 -1
-1 -3
-2 -3
Output #2
-1
InputCopy OutputCopy
Input #3
5
0 0
0 -1
3 0
-2 0
-2 1
Output #3
2
InputCopy OutputCopy
Input #4
5
0 0
2 0
0 -1
-2 0
-2 1
Output #4
2
InputCopy OutputCopy
题目信息
题号
1419F
时间限制
2 s
内存限制
256 MB
标签
二分
数据结构
DFS 及类似
并查集
图论
模拟

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