Codeforces Round 466 (Div. 2)
F
Machine Learning
Codeforces
2600
原题
← E→
翻译中…

You come home and fell some unpleasant smell. Where is it coming from?

翻译中…

You are given an array $*a*$. You have to answer the following queries:

翻译中…
  1. You are given two integers $*l*$ and $*r*$. Let $*c*_{*i*}$ be the number of occurrences of $*i*$ in $*a*_{*l*: *r*}$, where $*a*_{*l*: *r*}$ is the subarray of $*a*$ from $*l*$-th element to $*r*$-th inclusive. Find the Mex of ${*c*_{0}, *c*_{1}, ..., *c*_{10^{9}}}$
  2. You are given two integers $*p*$ to $*x*$. Change $*a*_{*p*}$ to $*x*$.
翻译中…

The Mex of a multiset of numbers is the smallest non-negative integer not in the set.

翻译中…

Note that in this problem all elements of $*a*$ are positive, which means that $*c*_{0}$ = 0 and $0$ is never the answer for the query of the second type.

翻译中…

Input

翻译中…

The first line of input contains two integers $*n*$ and $*q*$ ($1 ≤ *n*, *q* ≤ 100 000$) — the length of the array and the number of queries respectively.

翻译中…

The second line of input contains $*n*$ integers — $*a*_{1}$, $*a*_{2}$, $...$, $*a*_{*n*}$ ($1 ≤ *a*_{*i*} ≤ 10^{9}$).

翻译中…

Each of the next $*q*$ lines describes a single query.

翻译中…

The first type of query is described by three integers $*t*_{*i*} = 1$, $*l*_{*i*}$, $*r*_{*i*}$, where $1 ≤ *l*_{*i*} ≤ *r*_{*i*} ≤ *n*$ — the bounds of the subarray.

翻译中…

The second type of query is described by three integers $*t*_{*i*} = 2$, $*p*_{*i*}$, $*x*_{*i*}$, where $1 ≤ *p*_{*i*} ≤ *n*$ is the index of the element, which must be changed and $1 ≤ *x*_{*i*} ≤ 10^{9}$ is the new value.

翻译中…

Output

翻译中…

For each query of the first type output a single integer  — the Mex of ${*c*_{0}, *c*_{1}, ..., *c*_{10^{9}}}$.

翻译中…

Note

翻译中…

The subarray of the first query consists of the single element — $1$.

翻译中…

The subarray of the second query consists of four $2$s, one $3$ and two $1$s.

翻译中…

The subarray of the fourth query consists of three $1$s, three $2$s and one $3$.

翻译中…

样例

Input #1
10 4
1 2 3 1 1 2 2 2 9 9
1 1 1
1 2 8
2 7 1
1 2 8
Output #1
2
3
2
InputCopy OutputCopy
题目信息
题号
940F
时间限制
4 s
内存限制
512 MB
标签
暴力
数据结构

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。