You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
770 B
C++

#include <algorithm>
#include <map>
#include <cstdio>
#include <cstring>
using namespace std;
const int N=1e5+5;
int a[N];
int main()
{
int T,n,q,op,p,v;
scanf("%d",&T);
map<int,int> M;
while(T--)
{
M.clear();
scanf("%d%d",&n,&q);
for(int i=1; i<=n; i++)
scanf("%d",a+i),M[a[i]]++;
while(q--)
{
scanf("%d",&op);
if(op==1)
{
scanf("%d%d",&p,&v);
if((--M[a[p]])==0)
M.erase(a[p]);
M[a[p]=v]++;
}
if(op==2)
{
M.erase(0);
printf("%d\n",M.size());
}
}
}
return 0;
}