#P10078. [GDKOI2024 普及组] 正方形扩展

[GDKOI2024 普及组] 正方形扩展

Problem Description

Now, on the Cartesian coordinate system (an infinitely large 2D plane), there are nn bacteria of different types, and their coordinates are all distinct.

As time goes on, the bacteria keep reproducing. They expand their territory in the shape of squares, all with the same square expansion speed.

More specifically, for any time tt and any point pp on the plane, suppose there exists type ii bacteria at point pp. Then there are two cases:

  • If every square centered at point pp contains bacteria of other types, then the bacteria at this point will not expand (this can be called “contact inhibition”).

  • If there exists a square centered at pp that contains no bacteria of other types, then the bacteria at this point will expand.

Note that newly expanded bacteria of the same type also have the same expansion ability.

Here are some simple examples of square expansion:

If initially there is only one bacterium at (0,0)(0, 0) on the plane, then after one unit of time, this type of bacteria will occupy the square surrounded by (1,1)(1, 1), (1,1)(1, -1), (1,1)(-1, -1), (1,1)(-1, 1).

If initially there are two bacteria at (0,0)(0, 0) and (1,0)(1, 0), then eventually (0.5,0)(0.5, 0) will become the boundary line of their territories. The bacteria initially at (0,0)(0, 0) will occupy all the area to the left of (0.5,0)(0.5, 0), and the bacteria initially at (1,0)(1, 0) will occupy all the area to the right of (0.5,0)(0.5, 0).

Now, for the ii-th type of bacteria, you need to determine whether its occupied area can grow to infinity.

Input Format

The first line contains a positive integer n(1n106)n(1 \leq n \leq 10^6), indicating the number of bacterial mothers.

Then follow nn lines, each containing two integers, representing the point coordinates (xi,yi)(x_i, y_i), i.e., the position of the mother of type ii bacteria.

Output Format

Output a 0101 string of length nn. For the ii-th character, 11 means the occupied area of type ii bacteria can expand to infinity, and 00 means the final area is finite.

5
0 0
2 0
2 2
0 2
1 1
11110
3
-2 0
0 0
2 0
111
7
-7 -8
5 -9
1 -5
9 -4
-8 3
-2 -3
-4 -6
1101110

Hint

Sample Explanation

In the second sample, the territory finally owned by point (0,0)(0, 0) is the region between the lines x=1x = -1 and x=1x = 1, and its area tends to infinity.

Constraints

For 25%25\% of the testdata, n102n \leq 10^2.

For 50%50\% of the testdata, n103n \leq 10^3.

For 75%75\% of the testdata, n105n \leq 10^5.

For 100%100\% of the testdata, 1n1061\leq n \leq 10^6, 109xi,yi109-10^9 \leq x_i, y_i \leq 10^9.

Translated by ChatGPT 5