#P14773. [ICPC 2024 Seoul R] Square Stamping

[ICPC 2024 Seoul R] Square Stamping

题目描述

In the plane, there are n n points whose y-coordinates are either 9999 -9999 , 0 0 , or 9999 9999 . Let P P be the set of these n n points. Your task is to enclose all the points in P P by a minimum number of congruent axis-parallel squares of side length 10,000. As a subset of the plane, each such square consists of all points inside and on the boundary.

输入格式

Your program is to read from standard input. The input starts with a line consisting of a single integer n n (1n300,000 1 \leq n \leq 300,000 ), representing the number of input points in P P . In each of the following n n lines, there are two integers x x and y y , representing the x x - and y y -coordinates of a point in P P , respectively, such that it holds that 109x109 -10^9 \leq x \leq 10^9 and y{9999,0,9999} y \in \{-9999, 0, 9999\} . You may assume that all the n n input points are distinct.

输出格式

Your program is to write to standard output. Print exactly one line. The line should consist of a single integer that represents the minimum possible number t t such that there exist t t axis-parallel squares of side length 10,000 whose union encloses all the input points in P P .

5
0 9999
0 0
0 -9999
200 0
10000 9999
2
5
10 -9999
0 0
3 9999
9000 -9999
10003 9999
2
6
10 -9999
0 0
3 9999
9000 -9999
10003 -9999
10003 9999
3