UberOA #2
Obstacles and Blocks on a Number Line
Estimated MediumJudge-ready
Topics (AI-labelled)Binary SearchIterators
Operation 1 x places an obstacle at coordinate x; placing it again has no additional effect. Operation 2 x size checks whether the half-open range [x−size,x) contains no obstacle; if it is empty, record 1, otherwise record 0. Queries only check and never place obstacles; finally, concatenate all query results.
This site's standard input/output is stated explicitly.
Input
The first line contains q, followed by q lines of operations. 1≤q≤100000. This site's convention is −10⁹≤x≤10⁹ and 1≤size≤10⁹.
Output
Output the 01 string formed by the query results; if there are no queries, output an empty line.
Example 1
Input:
6
1 2
1 5
2 5 2
2 6 3
2 2 1
2 3 2
Output:
1010
Example 2
Input:
3
1 0
2 0 1
2 1 1
Output:
10
Example 3
Input:
1
2 -5 3
Output:
1
Example notes
Example 1: the queries [3,5), [3,6), [1,2), and [1,3) contain no, some, no, and some obstacles respectively, so the output is 1010. Example 2: the right end 0 does not belong to [−1,0) but does belong to [0,1), so the output is 10. Example 3: no obstacle is placed, so the output is 1.
Editorial
Loading solution…