#P10821. [EC Final 2020] Rooks

[EC Final 2020] Rooks

题目描述

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 n1n_1 rooks and Prof. Shou placed n2n_2 rooks. Each rook is a point with integer coordinates on the chessboard. One rook is attacked\textit{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 n1,n2n_1, n_2 (1n1,n22000001\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 (1in11\le i\le n_1) line of the next n1n_1 lines contains two integers x,yx, y (109x,y109-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 (1in21\le i\le n_2) line of the next n2n_2 lines contains two integers x,yx, y (109x,y109-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 n1+n2n_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 n1n_1 on the first line. The ii-th (1in11\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 n2n_2 on the second line. The ii-th (1in21\le i\le n_2) character should be 11 if the ii-th rook placed by Prof. Shou is attacked and 00 otherwise.

3 2
0 0
0 1
1 0
0 -1
-1 0
100
11