cswork / OAOpen practice workspace

MetaOA #12

Build Blocks and Obstacles on a Number Line

Estimated MediumJudge-ready

Topics (AI-labelled)Binary SearchIterators

Perform the operations in order: 1 x places an obstacle at the empty coordinate x; 2 x size checks whether the half-open range [x,x+size) contains no obstacle, outputting the character 1 if so and 0 otherwise. A check operation places nothing. Concatenate all check results into one string.

Input

This site's standard input scale: the first line contains q (1..100000); the next q lines are operations 1 x or 2 x size, with x in −10⁹..10⁹ and size in 1..10⁹. When an obstacle is placed, its coordinate is guaranteed to be empty, and there is at least one check.

Output

Output the answer as described; separate multiple results with spaces in order, and output an empty line for an empty array.

Example 1

Input:

6
1 2
1 5
2 3 2
2 3 3
2 1 1
2 1 2

Output:

1010

Example 2

Input:

3
2 0 1
1 0
2 0 1

Output:

10

Example 3

Input:

3
1 -2
2 -3 1
2 -3 2

Output:

10

Example notes

Example 1: the obstacles are at 2 and 5; the four queries [3,5), [3,6), [1,2), [1,3) are clear, blocked, clear, blocked in order, giving 1010.

Editorial

Loading solution…