CF329E.Evil
NOI/NOI+/CTSC
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are n cities on a two dimensional Cartesian plane. The distance between two cities is equal to the Manhattan distance between them (see the Notes for definition). A Hamiltonian cycle of the cities is defined as a permutation of all n cities. The length of this Hamiltonian cycle is defined as the sum of the distances between adjacent cities in the permutation plus the distance between the first and final city in the permutation. Please compute the longest possible length of a Hamiltonian cycle of the given cities.
二维笛卡尔平面上有 n 座城市。两座城市之间的距离定义为它们之间的曼哈顿距离(定义参见下方“说明”部分)。这些城市的哈密顿回路定义为所有 n 座城市的一个排列。该哈密顿回路的长度定义为:排列中相邻两座城市之间的距离之和,再加上排列中第一座城市与最后一座城市之间的距离。请计算给定城市所能构成的哈密顿回路的最大可能长度。
输入格式
The first line contains an integer n (3 ≤ n ≤ 105). Then n lines follow, each consisting of two integers x__i and y__i (0 ≤ x__i, y__i ≤ 109), denoting the coordinates of a city. All given points will be distinct.
第一行包含一个整数 n(3≤n≤105)。接下来有 n 行,每行包含两个整数 xi 和 yi(0≤xi,yi≤109),表示一座城市的坐标。所有给定的点互不相同。
输出格式
A single line denoting the longest possible length of a Hamiltonian cycle of the given cities. You should not output the cycle, only its length.
Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
表示给定城市所能构成的哈密顿回路的最大可能长度的单行数值。您无需输出该回路本身,仅需输出其长度。
请注意:在 C++ 中读写 64 位整数时,请勿使用 %lld 格式说明符。推荐使用 cin/cout 流,或使用 %I64d 格式说明符。
输入输出样例
输入#1
4 1 1 1 2 2 1 2 2
输出#1
6
说明/提示
In the example, one of the possible Hamiltonian cycles with length 6 is (1, 1) (1, 2) (2, 1) (2, 2). There does not exist any other Hamiltonian cycle with a length greater than 6.
The Manhattan distance between two cities (x__i, y__i) and (x__j, y__j) is |x__i - x__j| + |y__i - y__j|.
在示例中,一条可能的长度为 6 的哈密顿回路是 (1,1) (1,2) (2,1) (2,2)。不存在长度大于 6 的其他哈密顿回路。
两座城市 (xi, yi) 与 (xj, yj) 之间的曼哈顿距离为 ∣xi−xj∣+∣yi−yj∣。
输入解题思路,AI测评打分。不知道怎么写?