#P7712. [Ynoi2077] hlcpq

[Ynoi2077] hlcpq

Problem Description

On a plane, you are given nn horizontal line segments and nn vertical line segments. It is guaranteed that no two different segments lie on the same straight line.

If two segments have an intersection point, then they are connected. If a,ba, b are connected and b,cb, c are connected, then a,ca, c are connected.

A segment aa is critical if and only if there exist two other segments b,cb, c such that b,cb, c are connected, and after deleting aa, b,cb, c are no longer connected.

Input Format

The first line contains an integer nn.

The next nn lines: the ii-th line contains two integers l,rl, r (1l<rn1 \le l < r \le n), representing a horizontal segment with lxrl \le x \le r and y=iy=i.

The next nn lines: the ii-th line contains two integers d,ud, u (1d<un1 \le d < u \le n), representing a vertical segment with x=ix = i and dyud \le y \le u.

Output Format

Output two lines, each being a 0101 string of length nn.

The ii-th character of the first line is 11 if and only if the ii-th horizontal segment is critical.

The ii-th character of the second line is 11 if and only if the ii-th vertical segment is critical.

10
1 4
2 7
1 6
3 7
2 4
1 9
1 3
9 10
3 5
1 7
1 7
1 3
1 3
3 7
1 2
3 5
1 7
5 7
3 9
9 10
0100010000
1001000010

Hint

Idea: ccz181078, Solution: ccz181078, Code: ccz181078, Data: ccz181078&nzhtl1477

Constraints: for 100%100\% of the testdata, 2n1052 \le n \le 10^5.

Translated by ChatGPT 5