我大为不解
#include<bits/stdc++.h>
#define int long long//去掉会TLE
using namespace std;
const int N = 133340, V = 1000006;
template<class io>
inline void re(io &x)
{
char c=getchar();x=0;
while(c<48 || c>57)c=getchar();
while(c>47 && c<58)x=(x<<3)+(x<<1)+(c&15), c=getchar();
return;
}
template<class io>
void wr(io x)
{
io d=x/10;if(d)wr(d);
putchar(x-(d<<3)-(d<<1)|48);return;
}
int n, m;
int col[N], cnt[V];
int blc;
struct query
{
int L, R, T, id;
bool operator< (const query x) const
{
int l1 = L / blc, l2 = x.L / blc;
if(l1 != l2) return l1 < l2;
int r1 = R / blc, r2 = x.R / blc;
if(r1 != r2) return r1 < r2;
return (r1 & 1)? (T > x.T) : (T < x.T);
}
}Q[N];
struct replace
{
int pl, cl;
}rp[N];
int qn, ti;
int l = 1, r = 0, t = 0;
int ans = 0, res[N];
inline void add(int x)
{
++cnt[x];
if(cnt[x] == 1)++ans;
return;
}
inline void del(int x)
{
--cnt[x];
if(cnt[x] == 0)--ans;
}
inline void opr(int t)
{
int p = rp[t].pl;
int tmpCol = col[p];
col[p] = rp[t].cl;
rp[t].cl = tmpCol;
if(l <= p && p <= r)
{
del(tmpCol);
add(col[p]);
}
return;
}
char opt[2];
signed main()
{
re(n); re(m);
for(int i = 1; i <= n; ++i)
{
re(col[i]);
}
for(int i = 1; i <= m; ++i)
{
scanf("%s", opt);
if(opt[0] == 'Q')
{
int L, R;
re(L); re(R);
Q[++qn] = {L, R, ti, qn};
}
else if(opt[0] == 'R')
{
int P, Col;
re(P); re(Col);
rp[++ti] = {P, Col};
}
else puts("Err");
}
blc = (qn && ti) ? pow(2 * n * n * ti / qn, 1.0 / 3.0) : pow(n, 2.0 / 3.0);
sort(Q + 1, Q + qn + 1);
for(int i = 1; i <= qn; ++i)
{
while(l > Q[i].L) add(col[--l]);
while(r < Q[i].R) add(col[++r]);
while(l < Q[i].L) del(col[l]), ++l;
while(r > Q[i].R) del(col[r]), --r;
while(t < Q[i].T) ++t, opr(t);
while(t > Q[i].T) opr(t), --t;
res[Q[i].id] = ans;
}
for(int i = 1; i <= qn; ++i)
{
wr(res[i]);puts("");
}
return 0;
}