Logo
(追記) (追記ここまで)

33747번 - Get Mex Range Add Linear 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 2048 MB555100.000%

문제

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,ドル a sequence of $n$ sets. Initially, $a_i=\left\{ 0 \right\}$ (set only containing 0ドル$) for all 1ドル \le i \le n$.

You are asked to solve $q$ queries of the following kinds.

  • 1ドル$ $l$ $r$: Set $a_i \leftarrow a_i \cup \left\{i-l+1\right\}$ for all $l \le i \le r$. (1ドル \le l \le r \le n$)
  • 2ドル$ $i$: Output the value of $\text{mex}(a_i)$$^\dagger$. (1ドル \le i \le n$)

$^\dagger$ Given a set of nonnegative integers $S,ドル $\text{mex}(S)$ is defined as the smallest nonnegative integer not in $S$.

입력

The first line contains two integers $n$ and $q$ --- the number of sets and queries. (1ドル \le n,q \le 5\cdot 10^5$)

Each of the $q$ following lines contains a query. Each query is given in the format described above.

출력

For each query of type 2ドル,ドル print the answer on a new line.

제한

예제 입력 1

5 9
1 1 5
2 1
2 5
1 2 3
1 4 5
1 3 3
2 2
2 3
2 4

예제 출력 1

2
1
3
4
2

노트

The sample input is explained as follows.

After the first query of type 1ドル,ドル $a$ changes to $[\left\{ 0,1 \right\},\left\{ 0,2 \right\},\left\{ 0,3 \right\},\left\{ 0,4 \right\},\left\{ 0,5 \right\}]$.

Then, the $\text{mex}$ of $\left\{ 0,1 \right\}$ and $\left\{ 0,5 \right\}$ are 2ドル$ and 1ドル$ correspondingly.

After three more queries of type 1ドル,ドル $a$ 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 $\text{mex}$ of $\left\{ 0,1,2 \right\},ドル $\left\{ 0,1,2,3 \right\},ドル $\left\{ 0,1,4 \right\}$ are 3ドル,ドル 4ドル,ドル 2ドル$ correspondingly.

출처

Camp > Osijek Competitive Programming Camp > Summer 2024 > Day 5: OCPC Potluck Contest 2 G번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /