Get Mex Range Add Linear
시간 제한4초메모리 제한2048 MB
연속한 값을 집합에 넣는 구간 갱신을 처리하며 각 위치의 mex를 답하는 문제입니다.
문제
Sorry, we have had the theme of adding up integers so many times elsewhere. So we give you a different definition of addition --- adding an element to a set.
You are given , a sequence of sets. Initially, a\_i=\left\\{ 0 \right\\} (set only containing ) for all .
You are asked to solve queries of the following kinds.
- : Set a\_i \leftarrow a\_i \cup \left\\{i-l+1\right\\} for all . ()
- : Output the value of \text{mex}(a\_i)$$^\dagger. ()
Given a set of nonnegative integers , is defined as the smallest nonnegative integer not in .
입력
The first line contains two integers and --- the number of sets and queries. ()
Each of the following lines contains a query. Each query is given in the format described above.
출력
For each query of type , print the answer on a new line.
힌트
The sample input is explained as follows.
After the first query of type , changes to \[\left\\{ 0,1 \right\\},\left\\{ 0,2 \right\\},\left\\{ 0,3 \right\\},\left\\{ 0,4 \right\\},\left\\{ 0,5 \right\\}].
Then, the of \left\\{ 0,1 \right\\} and \left\\{ 0,5 \right\\} are and correspondingly.
After three more queries of type , changes to \[\left\\{ 0,1 \right\\},\left\\{ 0,1,2 \right\\},\left\\{ 0,1,2,3 \right\\},\left\\{ 0,1,4 \right\\},\left\\{ 0,2,5 \right\\}].
Then, the of \left\\{ 0,1,2 \right\\}, \left\\{ 0,1,2,3 \right\\}, \left\\{ 0,1,4 \right\\} are , , correspondingly.