시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
5 초 | 512 MB | 13 | 10 | 10 | 76.923% |
JOI Kingdom is represented by a xy-plane. There are N houses in JOI Kingdom numbered from 1 to N. The coordinate of the house i (1 ≤ i ≤ N) is (Xi, Yi). Different houses have different coordinates. A citizen lives in each house. The citizen in the house i is called the citizen i.
A long holiday season begins in JOI Kingdom. At time 0, every citizen leaves the house, and starts traveling. In the beginning, every citizen chooses one of ‘east’, ‘west’, ‘south’, ‘north’, which is the direction for traveling. The citizens will travel in the following way.
Unfortunately, at time 0, the citizen 1 is infected with IOI fever, which is a newly discovered infectious disease. At time 0, there are no infected people other than the citizen 1. The IOI fever is transmitted among citizens in the following way.
Assume that, at a certain time, the citizen a (1 ≤ a ≤ N) and the citizen b (1 ≤ b ≤ N) have the same coordinates, the citizen a is infected with IOI fever, and the citizen b is not infected with IOI fever. Then, the citizen b becomes infected with IOI fever.
The IOI fever is not transmitted by other methods. Moreover, since IOI fever is an incurable disease, infected citizen will not be recovered.
As a minister of JOI Kingdom, you need to estimate how many citizens will be infected with IOI fever if the citizens make the worst possible choice.
Write a program which, given the number of houses and the coordinate of each house, calculates the largest possible number of infected citizens at time 10100.
Read the following data from the standard input. Given values are all integers.
N X1 Y1 . . . XN YN
Write one line to the standard output. Output the largest possible number of infected citizens at time 10100.
번호 | 배점 | 제한 |
---|---|---|
1 | 5 | N ≤ 7, Xi ≠ Xj (1 ≤ i < j ≤ N), Yi ≠ Yj (1 ≤ i < j ≤ N) |
2 | 8 | N ≤ 15, Xi ≠ Xj (1 ≤ i < j ≤ N), Yi ≠ Yj (1 ≤ i < j ≤ N) |
3 | 6 | N ≤ 100, Xi ≠ Xj (1 ≤ i < j ≤ N), Yi ≠ Yj (1 ≤ i < j ≤ N), X1 = 0, Y1 = 0 |
4 | 6 | N ≤ 100, Xi ≠ Xj (1 ≤ i < j ≤ N), Yi ≠ Yj (1 ≤ i < j ≤ N) |
5 | 12 | N ≤ 3 000 |
6 | 32 | Xi ≠ Xj (1 ≤ i < j ≤ N), Yi ≠ Yj (1 ≤ i < j ≤ N) |
7 | 31 | No additional constraints. |
2 0 0 4 3
1
In this sample input, the positions of the houses are as follows.
For example, assume that the citizen 1 chooses ‘east’ and the citizen 2 chooses ‘west.’
Then, at any time, the coordinates of citizens 1 and 2 are different. Thus the citizen 2 will not be infected. Therefore the citizen 1 is the only infected citizen at time 10100. The number of infected citizens is 1.
Regardless of the choices of the directions of the citizens 1 and 2, the number of infected citizens cannot be larger than 1. Hence the largest possible number of infected citizens is 1, and output 1.
This sample input satisfies the constraints of Subtasks 1, 2, 3, 4, 5, 6, 7.
3 1 2 2 1 4 3
3
In this sample input, the positions of the houses are as follows.
For example, assume that the citizen 1 chooses ‘east,’ the citizen 2 chooses ‘north,’ the citizen 3 chooses ‘west.’ Then the IOI fever is transmitted among citizens in the following way.
Finally, the number of infected citizens becomes 3. Since it is the largest possible value, output 3.
This sample input satisfies the constraints of Subtasks 1, 2, 4, 5, 6, 7.
2 20 20 20 21
2
Assume that the citizen 1 chooses ‘north’ and the citizen 2 chooses ‘south.’ Then the IOI fever is transmitted among citizens in the following way.
Finally, the number of infected citizens becomes 2. Since it is the largest possible value, output 2.
This sample input satisfies the constraints of Subtasks 5, 7.
15 5 6 2 9 12 0 4 11 3 12 6 5 0 8 9 10 11 13 8 7 13 2 1 1 7 14 10 4 14 3
9
This sample input satisfies the constraints of Subtasks 2, 4, 5, 6, 7.
30 275810186 246609547 122805872 99671769 243507947 220373844 281305347 252104708 237805644 214671541 172469077 149334974 222589229 229887956 160653451 208404690 241378966 211098219 144302355 224755786 186392385 163258282 199129390 169928751 294937491 265736852 196096122 172962019 314342944 285142305 202720470 166337671 157037485 133903382 263858979 240724876 210720220 181519581 296402036 267201397 186021287 183036854 195081930 173976211 328293029 299092390 261195361 238061258 323595085 294394446 299933764 270733125 240976723 128081418 188501753 165367650 277832422 248631783 119896220 96762117
11
This sample input satisfies the constraints of Subtasks 4, 5, 6, 7.