CF1419F.Rain of Fire

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

There are nn detachments on the surface, numbered from 11 to nn, the ii-th detachment is placed in a point with coordinates (xi,yi)(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 tt 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 tt that it is possible to check each detachment. If there is no such tt report about it.

地表上有 nn 个分队,编号从 11 到 nn,其中第 ii 个分队位于坐标为 (xi,yi)(x_i, y_i) 的点上。所有分队均位于互不相同的点上。

Brimstone 必须至少访问每个分队一次。你可以任选一个分队作为 Brimstone 的起始位置。

从一个分队移动到另一个分队时,他需首先选择四个移动方向之一(上、右、左或下),然后以每秒一个单位长度的恒定速度沿该方向持续移动,直至抵达某个分队。当他到达任意一个分队后,可重复此过程。

每过 tt 秒,轨道打击将覆盖整个地表;因此在该时刻,Brimstone 必须恰好位于某个分队所在的位置。他可以在任一分队处停留任意长的时间。

Brimstone 是一位优秀的指挥官,因此他最多可以预先新建一个分队,并将其放置于任意一个坐标均为整数且当前无分队的空点上。注意:Brimstone 同样需要访问这个新建的分队。

请帮助 Brimstone 找出满足条件的最小 tt 值,使得他能够访问全部分队。若不存在这样的 tt,请报告该情况。

输入格式

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

In each of the next nn lines there is a pair of integers xix_i, yiy_i (∣xi∣,∣yi∣≤109)(|x_i|, |y_i| \le 10^9) — the coordinates of ii-th detachment.

It is guaranteed that all points are different.

第一行包含一个整数 nn(2≤n≤10002 \le n \le 1000)——小队的数量。

接下来的 nn 行中,每行包含一对整数 xix_i、yiy_i(∣xi∣,∣yi∣≤109|x_i|, |y_i| \le 10^9)——第 ii 个小队的坐标。

保证所有点互不相同。

输出格式

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

If there is no such tt, print −1-1.

输出满足条件的最小整数 tt:即最多新增一个分队,即可检查所有分队。

若不存在这样的 tt,则输出 −1-1。

输入输出样例

  • 输入#1

    4
    100 0
    0 100
    -100 0
    0 -100

    输出#1

    100
  • 输入#2

    7
    0 2
    1 0
    -3 0
    0 -2
    -1 -1
    -1 -3
    -2 -3

    输出#2

    -1
  • 输入#3

    5
    0 0
    0 -1
    3 0
    -2 0
    -2 1

    输出#3

    2
  • 输入#4

    5
    0 0
    2 0
    0 -1
    -2 0
    -2 1

    输出#4

    2

说明/提示

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

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

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

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

在第一个测试用例中,可以将一支分队放置在 (0,0)(0, 0) 处,使得 Brimstone 能在 t=100t = 100 时检查所有分队。可以证明:当 t<100t < 100 时,不可能检查所有分队;因此答案为 100100。

在第二个测试用例中,无论添加至多一支新分队,都不存在满足条件的 tt,使得 Brimstone 能检查所有分队,因此答案为 −1-1。

在第三个测试用例中,可以将一支分队放置在 (1,0)(1, 0) 处,使得 Brimstone 能在 t=2t = 2 时检查所有分队。可以证明:这是满足条件的最小 tt。

在第四个测试用例中,无需添加任何分队,因为答案不会更优(即 t=2t = 2)。可以证明:这是满足条件的最小 tt。

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

首页