#K75082. Nested Sequence Operations
Nested Sequence Operations
Nested Sequence Operations
We define a Nested Sequence data structure which supports three operations:
- add L R – Add a new range to the sequence.
- check x – Check whether the integer lies in any of the current ranges. An integer is considered inside a range if .
- merge v w – Merge the range at index v with the range at index w. The merged range becomes the union of the two, i.e. if the ranges are and , then the new range is .
The operations are provided via standard input. For eachcheck
operation, output the result to standard output.
inputFormat
The first line contains an integer , the number of operations. Each of the following lines contains an operation in one of the following formats:
• add L R • check x • merge v w
Note: For the merge operation, indices are -based and refer to the order in which ranges were added.
outputFormat
For each check
operation, output a single line containing either 'Yes' if the queried integer is contained in any active range, or 'No' otherwise.## sample
4
add 1 5
add 10 15
check 3
check 6
Yes
No
</p>