logo AlgoBeat OnlineJudge
登录 注册

#216591. [ICPC 2026 LAC] Kitten Greetings

内存限制:1024 MiB 时间限制:6000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Catarina loves all cats that live in her neighborhood. Her lifelong dream is to design a large cat-seeing circuit, so that every day she can go out and greet the cats while doing some exercise. Catarina's neighborhood can be represented as the 2D plane, with the North-South direction aligned with the -axis. A cat-seeing circuit that visits cats consists of exactly steps. Catarina chooses a starting position and faces one of the four cardinal directions. For each step the following occurs:

  • Catarina chooses a value and walks units from straight ahead in her current direction, stopping at the location of a cat that she has not greeted during any previous step.
  • Catarina greets the cat, taking some time to appreciate its beauty.
  • Without turning around, Catarina walks another units straight ahead in her current direction, stopping at a position .
  • Catarina turns either clockwise or counterclockwise, facing again one of the four cardinal directions.

After completing all steps, Catarina must be back to her starting position , facing her initial direction. Notice that the length of the cat-seeing circuit is . When , the cat-seeing circuit has length .

Catarina knows the location of the cats that live in her neighborhood. Surprisingly, no two cats have the same -coordinate or the same -coordinate. Your task is to determine the maximum length that a cat-seeing circuit can have.

输入格式

The first line contains an integer () indicating the number of cats.

Each of the next lines describes a cat with two integers and (), representing that the cat has coordinates .

No two cats have the same -coordinate or -coordinate (they differ in both of them).

输出格式

Output a single line with an integer indicating the maximum length that a cat-seeing circuit can have.

样例

样例输入 1

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

样例输出 1

0

样例输入 2

6
4 0
0 4
2 -1
-1 2
-4 3
3 -4

样例输出 2

32

样例输入 3

7
2 1
0 -1
5 5
3 0
4 4
6 2
1 -2

样例输出 3

24

数据范围与提示

Explanation of Sample 1:

In this case there is a circuit of length that visits all the cats, but it is not a cat-seeing circuit because the cat at coordinates is greeted twice.

Explanation of Sample 2:

The picture below shows the location of the cats with small circles, together with a maximum-length cat-seeing circuit that visits all of them. The length of the circuit is .

:::align{center} :::

Explanation of Sample 3:

It is possible to visit of the cats with a cat-seeing circuit of length .

:::align{center} :::