DatabricksOA #5
Rectangle Fit in Box (with Rotation)
估计简单可在线判题
Execute two kinds of operations in order: 0 a b stores an a×b rectangle; 1 a b asks whether every previously stored rectangle can individually fit into an a×b query box. Rectangles may be rotated 90 degrees; each rectangle is placed separately, and they do not need to fit into the same box at the same time.
Standard input/output, this site's supplementary ranges, and the examples follow this problem's description.
输入格式
The first line contains q (1≤q≤30000), followed by q lines each containing kind, a, and b. kind is 0 or 1, and 1≤a,b≤10⁹. These ranges are site supplements that keep the worst-case output length within the judge's limit.
输出格式
Output one line per query operation: 1 if they fit, otherwise 0. When no rectangles have been stored, the query result is 1.
样例 1
输入:
4
0 1 3
0 4 2
1 3 4
1 3 2
输出:
1
0
样例 2
输入:
4
1 1 1
0 2 5
1 5 2
1 4 2
输出:
1
1
0
样例 3
输入:
4
0 2 2
0 3 1
1 3 2
1 3 3
输出:
1
1