Logo
(追記) (追記ここまで)

27290번 - Towers 서브태스크스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB82141215.789%

문제

Benson the Rabbit likes towers. There are $N$ cities numbered 1ドル$ to $N,ドル and city $i$ is located at a point with integer coordinates $(X_i , Y_i)$. No two cities are located at the same point. Benson wants to build towers in some of these cities such that the following conditions are satisfied:

  • For any $a,ドル there are at most two towers with $x$-coordinate equal to $a$.
  • For any $b,ドル there are at most two towers with $y$-coordinate equal to $b$.
  • Each of the $N$ cities either has a tower built, or lies on the line segment between two towers with the same $x$-coordinate or the same $y$-coordinate. More formally, for a city located at $(x, y),ドル if there is no tower in that city, then there are two towers at coordinates $(x, c),ドル $(x, d)$ with $c ≤ y ≤ d,ドル or two towers at coordinates $(e, y),ドル $(f, y)$ with $e ≤ x ≤ f$.

Benson knows that it is always possible to build towers satisfying these conditions, but does not know how he should do so. Help Benson determine where he should build the towers.

입력

Your program must read from standard input.

The first line of the input contains one integer, $N,ドル the number of cities.

In the next $N$ lines, the $i$th line contains two integers $X_i,ドル $Y_i,ドル which means city $i$ is located at the point $(X_i , Y_i)$.

출력

Your program must print to standard output.

Output one line containing a string of $N$ characters $A_1A_2 \cdots A_N$. $A_i$ should be 1ドル$ if Benson should build a tower in city $i,ドル and 0ドル$ otherwise. The towers built should satisfy all the conditions.

If there are several solutions your program can output any one of them.

제한

  • 1ドル ≤ N ≤ 10^6$
  • 1ドル ≤ X_i , Y_i ≤ 10^6$
  • For all $i \ne j,ドル either $X_i \ne X_j$ or $Y_i \ne Y_j$.

서브태스크

번호배점제한
15

$N ≤ 3$

211

$N ≤ 16$

37

$N = ab$ for some positive integers $a,ドル $b$ and $(X_{ai+j} , Y_{ai+j}) = (i + 1, j)$ for all integers $i,ドル $j$ with 0ドル ≤ i ≤ b - 1,ドル 1ドル ≤ j ≤ a$

46

For every integer $a,ドル there are at most two cities whose $x$-coordinate is $a$.

531

$N ≤ 5000$

621

$N ≤ 100000$

719

-

예제 입력 1

3
1 1
1 6
1 5

예제 출력 1

110

If we build towers in cities 1ドル$ and 2ドル$ which have the same $x$-coordinate, city 3ドル$ which also has the same $x$-coordinate lies on the line segment between them.

An example of an incorrect output would be 111ドル,ドル as there will be more than two towers having $x$-coordinate equal to 1ドル$ if towers are built in all 3ドル$ cities.

Another incorrect output is 101ドル,ドル as even though city 2ドル$ shares the same $y$-coordinate with cities 1ドル$ and 3ドル,ドル it does not lie on the line segment between them.

This testcase is valid for subtasks 1, 2, 5, 6, and 7.

예제 입력 2

6
1 1
1 2
2 1
2 2
3 1
3 2

예제 출력 2

110011

City 3ドル$ lies on the line segment between cities 1ドル$ and 5ドル$ which have the same $y$-coordinate, and city 4ドル$ lies on the line segment between cities 2ドル$ and 6ドル$ which have the same $y$-coordinate.

This testcase is valid for subtasks 2, 3, 4, 5, 6, and 7.

예제 입력 3

8
1 13
2 13
7 27
7 13
7 2
2 27
7 4
4 13

예제 출력 3

10101101

This testcase is valid for subtasks 2, 5, 6, and 7.

힌트

출처

Olympiad > National Olympiad in Informatics (Singapore) > NOI 2022 3번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /