QOJ.ac

QOJ

Time Limit: 5 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#3093. IOI 热潮

Statistics

JOI 王国由一个 $xy$ 平面表示。JOI 王国中有 $N$ 座房屋,编号从 $1$ 到 $N$。第 $i$ 座房屋($1 \le i \le N$)的坐标为 $(X_i, Y_i)$。不同的房屋坐标不同。每座房屋里住着一名市民。住在第 $i$ 座房屋的市民被称为市民 $i$。

JOI 王国迎来了一个长假。在时间 $0$,每位市民离开房屋并开始旅行。起初,每位市民从“东”、“西”、“南”、“北”中选择一个方向进行旅行。市民将按以下方式旅行:

  • 如果市民 $i$ 选择“东”,该市民将沿 $x$ 轴向正方向以速度 $1$ 移动。换句话说,在时间 $t$($t \ge 0$),市民 $i$ 的坐标变为 $(X_i + t, Y_i)$。
  • 如果市民 $i$ 选择“西”,该市民将沿 $x$ 轴向负方向以速度 $1$ 移动。换句话说,在时间 $t$($t \ge 0$),市民 $i$ 的坐标变为 $(X_i - t, Y_i)$。
  • 如果市民 $i$ 选择“南”,该市民将沿 $y$ 轴向负方向以速度 $1$ 移动。换句话说,在时间 $t$($t \ge 0$),市民 $i$ 的坐标变为 $(X_i, Y_i - t)$。
  • 如果市民 $i$ 选择“北”,该市民将沿 $y$ 轴向正方向以速度 $1$ 移动。换句话说,在时间 $t$($t \ge 0$),市民 $i$ 的坐标变为 $(X_i, Y_i + t)$。

不幸的是,在时间 $0$,市民 $1$ 感染了 IOI 热,这是一种新发现的传染病。在时间 $0$,除了市民 $1$ 外没有其他人感染。IOI 热在市民之间的传播方式如下:

假设在某一时刻,市民 $a$($1 \le a \le N$)和市民 $b$($1 \le b \le N$)坐标相同,市民 $a$ 感染了 IOI 热,而市民 $b$ 未感染 IOI 热。那么,市民 $b$ 将感染 IOI 热。

IOI 热不会通过其他方式传播。此外,由于 IOI 热是一种不治之症,感染的市民不会康复。

作为 JOI 王国的部长,你需要估计如果市民做出最坏的选择,会有多少市民感染 IOI 热。

编写一个程序,给定房屋数量和每座房屋的坐标,计算在时间 $10^{100}$ 时感染市民的最大可能数量。

输入格式

从标准输入读取以下数据。给定值均为整数。

$N$ $X_1$ $Y_1$ $\vdots$ $X_N$ $Y_N$

输出格式

向标准输出写入一行。输出在时间 $10^{100}$ 时感染市民的最大可能数量。

数据范围

  • $1 \le N \le 100\,000$
  • $0 \le X_i \le 500\,000\,000$ ($1 \le i \le N$)
  • $0 \le Y_i \le 500\,000\,000$ ($1 \le i \le N$)
  • $(X_i, Y_i) \neq (X_j, Y_j)$ ($1 \le i < j \le N$)

子任务

  1. (5 分) $N \le 7$,$X_i \neq X_j$ ($1 \le i < j \le N$),$Y_i \neq Y_j$ ($1 \le i < j \le N$)。
  2. (8 分) $N \le 15$,$X_i \neq X_j$ ($1 \le i < j \le N$),$Y_i \neq Y_j$ ($1 \le i < j \le N$)。
  3. (6 分) $N \le 100$,$X_i \neq X_j$ ($1 \le i < j \le N$),$Y_i \neq Y_j$ ($1 \le i < j \le N$),$X_1 = 0$,$Y_1 = 0$。
  4. (6 分) $N \le 100$,$X_i \neq X_j$ ($1 \le i < j \le N$),$Y_i \neq Y_j$ ($1 \le i < j \le N$)。
  5. (12 分) $N \le 3\,000$。
  6. (32 分) $X_i \neq X_j$ ($1 \le i < j \le N$),$Y_i \neq Y_j$ ($1 \le i < j \le N$)。
  7. (31 分) 无附加限制。

样例

样例输入 1

2
0 0
4 3

样例输出 1

1

样例输入 2

3
1 2
2 1
4 3

样例输出 2

3

样例输入 3

2
20 20
20 21

样例输出 3

2

样例输入 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

样例输出 4

9

样例输入 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

样例输出 5

11

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.