Rooks

시간 제한2초메모리 제한1024 MB

요약
평면 위에 두 사람이 룩을 놓고, 같은 행이나 열에서 사이에 다른 룩 없이 상대 룩의 공격을 받는 룩을 가린다.
난이도

보통10점 중 6점

유형
정렬, 구현, 해시맵
정답자
아직 제출이 없습니다

문제

Prof. Pang plays chess against his rival Prof. Shou. They are the only two players in the game. The chessboard is very large and can be viewed as a 2D plane. Prof. Pang placed n_1n\_1 rooks and Prof. Shou placed n_2n\_2 rooks. Each rook is a point with integer coordinates on the chessboard. One rook is attacked by another rook if they satisfy all of the following conditions:

  • They are placed by different players.
  • They have the same xx-coordinate or yy-coordinate.
  • There is no other rook on the line segment between them.

Help Prof. Pang and Prof. Shou to decide which rooks are attacked.

입력

The first line contains two integers n_1,n_2n\_1, n\_2 (1≤n_1,n_2≤2000001\le n\_1, n\_2\le 200000) separated by a single space denoting the number of rooks placed by Prof. Pang and the number of rooks placed by Prof. Shou.

The ii-th (1≤i≤n_11\le i\le n\_1) line of the next n_1n\_1 lines contains two integers x,yx, y (−109≤x,y≤109-10^9\le x, y\le 10^9) separated by a single space denoting the location (x,y)(x, y) of the ii-th rook placed by Prof. Pang.

The ii-th (1≤i≤n_21\le i\le n\_2) line of the next n_2n\_2 lines contains two integers x,yx, y (−109≤x,y≤109-10^9\le x, y\le 10^9) separated by a single space denoting the location (x,y)(x, y) of the ii-th rook placed by Prof. Shou.

It is guaranteed that the n_1+n_2n\_1+n\_2 rooks placed by the players are distinct (i.e., no two rooks can have the same location).

출력

Output a string with length n_1n\_1 on the first line. The ii-th (1≤i≤n_11\le i\le n\_1) character should be 11 if the ii-th rook placed by Prof. Pang is attacked and 00 otherwise.

Output a string with length n_2n\_2 on the second line. The ii-th (1≤i≤n_21\le i\le n\_2) character should be 11 if the ii-th rook placed by Prof. Shou is attacked and 00 otherwise.

예제1

  1. 예제 1

    입력
    3 2
    0 0
    0 1
    1 0
    0 -1
    -1 0
    
    예상 출력
    100
    11