CF85E.Guard Towers
省选/NOI-
通过率:0%
时间限制:1.50s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
In a far away kingdom lives a very greedy king. To defend his land, he built n guard towers. Apart from the towers the kingdom has two armies, each headed by a tyrannical and narcissistic general. The generals can't stand each other, specifically, they will never let soldiers of two armies be present in one tower.
During defence operations to manage a guard tower a general has to send part of his army to that tower. Each general asks some fee from the king for managing towers. As they live in a really far away kingdom, each general evaluates his fee in the following weird manner: he finds two remotest (the most distant) towers, where the soldiers of his army are situated and asks for the fee equal to the distance. Each tower is represented by a point on the plane with coordinates (x, y), and the distance between two points with coordinates (_x_1, _y_1) and (_x_2, _y_2) is determined in this kingdom as |_x_1 - _x_2| + |_y_1 - _y_2|.
The greedy king was not exactly satisfied with such a requirement from the generals, that's why he only agreed to pay one fee for two generals, equal to the maximum of two demanded fees. However, the king is still green with greed, and among all the ways to arrange towers between armies, he wants to find the cheapest one. Each tower should be occupied by soldiers of exactly one army.
He hired you for that. You should find the minimum amount of money that will be enough to pay the fees. And as the king is also very scrupulous, you should also count the number of arrangements that will cost the same amount of money. As their number can be quite large, it is enough for the king to know it as a remainder from dividing by 109 + 7.
Two arrangements are distinct if the sets of towers occupied by soldiers of the first general are distinct.
在一个遥远的王国中,住着一位极其贪婪的国王。为了保卫国土,他建造了 n 座哨塔。除这些哨塔外,王国还拥有两支军队,每支军队各由一位专横且自恋的将军统帅。两位将军彼此厌恶,具体而言,他们绝不允许两支军队的士兵同时驻守于同一座哨塔中。
在防御行动期间,要管理某座哨塔,一名将军必须向该塔派遣其军队的一部分士兵。每位将军都会向国王索取管理哨塔的费用。由于他们生活在极为遥远的王国中,每位将军以如下奇特方式评估其收费:他找出其军队士兵所驻守的所有哨塔中距离最远(即曼哈顿距离最大)的两座塔,并索取等于该距离的费用。每座哨塔由平面上的一个点表示,其坐标为 (x,y);而坐标分别为 (x1,y1) 与 (x2,y2) 的两点之间的距离,在该王国中定义为 ∣x1−x2∣+∣y1−y2∣。
这位贪婪的国王对将军们提出的这种收费要求并不十分满意,因此他仅同意为两位将军支付一笔总费用,金额等于二者所索要费用中的较大者。然而,国王依旧被贪婪驱使,希望在所有将哨塔分配给两支军队的方式中,找出总费用最低的方案。每座哨塔必须且只能由其中一支军队的士兵驻守。
为此,国王雇佣了你。你需要求出足以支付费用的最小金额;并且,由于国王也极为细致,你还需计算出花费该最小金额的不同分配方案数目。由于该数目可能非常大,你只需输出其对 109+7 取模的结果即可。
若两名将军各自所驻守的哨塔集合不同,则称这两种分配方案互不相同。
输入格式
The first line contains an integer n (2 ≤ n ≤ 5000), n is the number of guard towers. Then follow n lines, each of which contains two integers x, y — the coordinates of the i-th tower (0 ≤ x, y ≤ 5000). No two towers are present at one point.
Pretest 6 is one of the maximal tests for this problem.
第一行包含一个整数 n(2≤n≤5000),表示哨塔的数量。接下来的 n 行中,每行包含两个整数 x、y —— 表示第 i 座哨塔的坐标(0≤x,y≤5000)。任意两座哨塔不会位于同一点。
预测试用例 6 是本题的一个最大规模测试用例。
输出格式
Print on the first line the smallest possible amount of money that will be enough to pay fees to the generals.
Print on the second line the number of arrangements that can be carried out using the smallest possible fee. This number should be calculated modulo 1000000007 (109 + 7).
第一行输出足以支付将军们费用的最小可能金额。
第二行输出使用该最小费用所能执行的安排方案数。该数值需对 1000000007(109+7)取模。
输入输出样例
输入#1
2 0 0 1 1
输出#1
0 2
输入#2
4 0 0 0 1 1 0 1 1
输出#2
1 4
输入#3
3 0 0 1000 1000 5000 5000
输出#3
2000 2
说明/提示
In the first example there are only two towers, the distance between which is equal to 2. If we give both towers to one general, then we well have to pay 2 units of money. If each general receives a tower to manage, to fee will be equal to 0. That is the smallest possible fee. As you can easily see, we can obtain it in two ways.
在第一个例子中,仅有两座塔,它们之间的距离为 2。如果我们把这两座塔都分配给同一位将军管理,则需要支付 2 单位金钱;如果每位将军各管理一座塔,则费用为 0。这是可能的最小费用。正如您很容易看出的那样,我们可以通过两种方式实现这一最小费用。
输入解题思路,AI测评打分。不知道怎么写?