DatabricksOA #6
Number Line — Obstacles + Block Fit
估计中等可在线判题
On the integer number line, process in order operations that either place an obstacle or ask whether an interval of length size can be placed. 1 x places an obstacle at x (it is guaranteed that there is no obstacle there yet); 2 x size checks integer coordinates x-size through x-1 (inclusive) without actually placing the interval.
Standard input/output, this site's supplementary ranges, and the examples follow this problem's description.
输入格式
The first line contains q (1≤q≤60000), followed by q lines of operations 1 x or 2 x size. −10⁹≤x≤10⁹, 1≤size≤10⁹. Inserted coordinates are guaranteed not to be occupied already; the upper bound on q is a site supplement that keeps the output length within the judge's limit.
输出格式
Concatenate the results of every 2 x size in order into a single string of 0s and 1s: 1 if the interval has no obstacle, otherwise 0.
样例 1
输入:
6
1 2
1 5
2 5 2
2 6 3
2 2 1
2 3 2
输出:
1010
样例 2
输入:
3
2 0 1
1 0
2 0 1
输出:
11
样例 3
输入:
3
1 -2
2 -3 1
2 -3 2
输出:
11