#P16557. [ICPC 2026 LAC] Kitten Greetings
[ICPC 2026 LAC] Kitten Greetings
题目描述
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.
5
1 2
2 1
0 0
-1 -2
-2 -1
0
6
4 0
0 4
2 -1
-1 2
-4 3
3 -4
32
7
2 1
0 -1
5 5
3 0
4 4
6 2
1 -2
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}
:::