P29123 [洛谷] [JOISC 2021 Day1] IOI Fever Infection Spread
省选
题目描述

Problem Description

In the kingdom of JOI, there are $N$ palaces, with the $i$-th palace located at coordinates $(X_i, Y_i)$. Each palace houses a prince, and the prince in the $i$-th palace is designated as Prince $i$. Starting from time $0$, each prince will leave their palace and begin to move in one of the four cardinal directions:

  • If moving east, the coordinates change from $(x, y)$ to $(x + t, y)$ after $t$ units of time.
  • If moving west, the coordinates change from $(x, y)$ to $(x - t, y)$ after $t$ units of time.
  • If moving south, the coordinates change from $(x, y)$ to $(x, y - t)$ after $t$ units of time.
  • If moving north, the coordinates change from $(x, y)$ to $(x, y + t)$ after $t$ units of time.

$t$ is not necessarily an integer.

The direction of movement is not predetermined and can be planned.

Unfortunately, Prince 1 has contracted the IOVID-114514 virus, and at time $0$, only Prince 1 is infected.

The IOVID-114514 virus spreads as follows:

  • If at any time, Prince $a$ and Prince $b$ are at the same coordinates, and Prince $a$ is infected while Prince $b$ is not, Prince $a$ will transmit the virus to Prince $b$.

The IOVID-114514 virus does not spread through other means, and the unfortunate King JOI 114514 has not discovered a cure.

(Even disinfectant cannot cure it!)

King JOI 114514 wants to know how many princes will be infected with the IOVID-114514 virus by time $10^{100}$.

Input Format

The first line contains an integer $N$, representing the number of palaces.

The next $N$ lines each contain two integers $X_i$ and $Y_i$, representing the coordinates of a palace.

Output Format

Output a single integer representing the answer.

Sample Input and Output

Input Sample #1

2
0 0
4 3

Output Sample #1

1

Input Sample #2

3
1 2
2 1
4 3

Output Sample #2

3

Input Sample #3

2
20 20
20 21

Output Sample #3

2

Input Sample #4

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

Output Sample #4

9

Input Sample #5

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

Output Sample #5

11

Notes/Hints

Sample 1 Explanation

We plan for Prince 1 to move east and Prince 2 to move west.

It is easy to see that no matter how they move, Prince 1 and Prince 2 will never meet, leaving only Prince 1 as the infected individual.

Sample 2 Explanation

We plan for Prince 1 to move east, Prince 2 to move north, and Prince 3 to move west.

  • At time $0$, Prince 1 is infected.
  • At time $1$, Prince 1 and Prince 2 are at the same coordinates, infecting Prince 2.
  • At time $2$, Prince 2 and Prince 3 are at the same coordinates, infecting Prince 3.

Sample 3 Explanation

We plan for Prince 1 to move north and Prince 2 to move south.

  • At time $0$, Prince 1 is infected.
  • At time $0.5$, Prince 1 and Prince 2 are at the same coordinates, infecting Prince 2.

Data Constraints and Specifications

This problem uses batched testing.

  • Subtask 1 (5 pts): $N \le 7$, satisfying Property A.
  • Subtask 2 (8 pts): $N \le 15$, satisfying Property A.
  • Subtask 3 (6 pts): $N \le 100$, satisfying Properties A and B.
  • Subtask 4 (6 pts): $N \le 100$, satisfying Property A.
  • Subtask 5 (12 pts): $N \le 3000$.
  • Subtask 6 (32 pts): Satisfying Property A.
  • Subtask 7 (31 pts): No special restrictions.

For $100\%$ of the data, $1 \le N \le 10^5$, $0 \le X_i, Y_i \le 5 \times 10^8$, and the palace coordinates are unique.

Properties include:

  • Property A: $X_i \ne X_j$, $Y_i \ne Y_j$.
  • Property B: The coordinates of Palace 1 are at the origin.

Notes

Translated from the 20th Japanese Olympiad in Informatics Spring Training Camp Day1 B IOI 熱の感染拡大 (IOI Fever) English version.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 0 0 4 3
样例输出
1