#P51451. [JOISC 2021 Day1] IOI Fever

[JOISC 2021 Day1] IOI Fever

Description

Original problem at JOISC 2021 Day1 T2 IOI Fever

JOI Kingdom is represented by a xy-plane. There are NN houses in JOI Kingdom numbered from 11 to NN. The coordinate of the house ii (1iN)(1 \leq i \leq N) is (Xi,Yi)(X_i, Y_i). Different houses have different coordinates. A citizen lives in each house. The citizen in the house ii is called the citizen ii. A long holiday season begins in JOI Kingdom. At time 00, 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.

  • If the citizen ii chooses east, the citizen moves along the xx-axis toward the positive direction with speed 11. In other words, at time tt (t0)(t \geq 0), the coordinates of the citizen ii becomes (Xi+t,Yi)(X_i + t, Y_i).
  • If the citizen ii chooses west, the citizen moves along the xx-axis toward the negative direction with speed 11. In other words, at time tt (t0)(t \geq 0), the coordinates of the citizen ii becomes (Xit,Yi)(X_i − t, Y_i).
  • If the citizen ii chooses south, the citizen moves along the yy-axis toward the negative direction with speed 11. In other words, at time tt (t0)(t \geq 0), the coordinates of the citizen ii becomes (Xi,Yit)(X_i, Y_i − t).
  • If the citizen ii chooses north, the citizen moves along the yy-axis toward the positive direction with speed 11. In other words, at time tt (t0)(t \geq 0), the coordinates of the citizen ii becomes (Xi,Yi+t)(X_i, Y_i + t).

Unfortunately, at time 00, the citizen 11 is infected with IOI fever, which is a newly discovered infectious disease. At time 00, there are no infected people other than the citizen 11. The IOI fever is transmitted among citizens in the following way.

  • Assume that, at a certain time, the citizen aa (1aN)(1 \leq a \leq N) and the citizen bb (1bN)(1 \leq b \leq N) have the same coordinates, the citizen aa is infected with IOI fever, and the citizen b is not infected with IOI fever. Then, the citizen bb 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 1010010^100.

Input Format

In the first line, there is a only integer NN.

In the following NN lines, there are two integers XiX_i and YiY_i in each line.

Output Format

Write one line to the standard output. Output the largest possible number of infected citizens at time 1010010^100.

Sample 1

2
0 0
4 3

1

In this sample input, the positions of the houses are as follows.

sample1

For example, assume that the citizen 11 chooses east and the citizen 22 chooses west.

Then, at any time, the coordinates of citizens 11 and 22 are different. Thus the citizen 22 will not be infected. Therefore the citizen 11 is the only infected citizen at time 1010010^100. The number of infected citizens is 11.

Regardless of the choices of the directions of the citizens 11 and 22, the number of infected citizens cannot be larger than 11. Hence the largest possible number of infected citizens is 11, and output 11.

This sample input satisfies the constraints of subtasks 1,2,3,4,5,6,71, 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.

sample2

For example, assume that the citizen 11 chooses east, the citizen 22 chooses north, the citizen 33 chooses west. Then the IOI fever is transmitted among citizens in the following way.

  • At time 00, the citizen 11 is the only infected citizen.
  • At time 11, the coordinates of the citizens 1,2,31, 2, 3 are (2,2),(2,2),(3,3)(2, 2), (2, 2), (3, 3), respectively. The coordinates of the citizens 11 and 22 are the same. At that time, the citizen 11 is infected with IOI fever, and the citizen 22 is not infected with IOI fever. Hence the citizen 22 becomes infected with IOI fever.
  • At time 22, the coordinates of the citizens 1,2,31, 2, 3 are (3,2),(2,3),(2,3)(3, 2), (2, 3), (2, 3), respectively. The coordinates of the citizens 22 and 33 are the same. At that time, the citizen 22 is infected with IOI fever, and the citizen 33 is not infected with IOI fever. Hence the citizen 33 becomes infected with IOI fever.

Finally, the number of infected citizens becomes 33. Since it is the largest possible value, output 33.

This sample input satisfies the constraints of subtasks 1,2,4,5,6,71, 2, 4, 5, 6, 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

Assume that the citizen 11 chooses north and the citizen 22 chooses south. Then the IOI fever is transmitted among citizens in the following way.

  • At time 00, the citizen 11 is the only infected citizen.
  • At time 0.50.5, both of the coordinates of the citizens 1, 21,~2 are (20,20.5)(20, 20.5).

At that time, the citizen 11 is infected with IOI fever, and the citizen 22 is not infected with IOI fever. Hence the citizen 22 becomes infected with IOI fever. Finally, the number of infected citizens becomes 22. Since it is the largest possible value, output 22.

This sample input satisfies the constraints of subtasks 5,75, 7.

2
20 20
20 21

2

This sample input satisfies the constraints of subtasks 2,4,5,6,72, 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,74, 5, 6, 7.

Constraints

For all test data, it is guaranteed that 1N105,1 \le N \le {10}^5, 1Xi,Yi5×108,1 \le X_i, Y_i \le 5 \times {10}^8, (Xi,Yi)(Xj,Yj) (1i<jN)(X_i, Y_i) \ne (X_j, Y_j)~(1\le i < j\le N).

Subtask Score Additional Constraints
11 55 N7,N \le 7, XiXj,X_i \ne X_j, YiYjY_i \ne Y_j
22 88 N15,N \le 15, XiXj,X_i \ne X_j, YiYjY_i \ne Y_j
33 66 N100,N \le 100, XiXj,X_i \ne X_j, YiYj,Y_i \ne Y_j, X1=0,X_1 = 0, Y1=0Y_1 = 0
44 N100,N \le 100, XiXj,X_i \ne X_j, YiYjY_i \ne Y_j
55 1212 N3000N \le 3000
66 3232 XiXj,X_i \ne X_j, YiYjY_i \ne Y_j
77 3131 No additional constraints