Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "bits/stdc++.h"
- using namespace std;
- #define sync \
- ios_base::sync_with_stdio(0); \
- cin.tie(0); \
- cout.tie(0)
- typedef long long ll;
- typedef unsigned long long ull;
- typedef pair<int,int> pii;
- typedef vector<int> vi;
- typedef long double ld;
- typedef pair<long long, long long> pll;
- #define ALL(V) V.begin(), V.end()
- #define SZ(V) (int)V.size()
- #define pb push_back
- #define mp make_pair
- #define fopen freopen("input.txt", "r", stdin); freopen("output.txt","w", stdout)
- #define FOR(i, a, b) for(int i = (a); i < (b); ++i)
- #define FORR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
- #define REP(i, N) FOR(i, 0, N)
- #define REPR(i, N) RFOR(i, N, 0)
- #define FILL(A,value) memset(A,value,sizeof(A))
- #define f first
- #define s second
- #define ff first
- #define ss second
- const int MOD = 1e9+7;
- const int INF = 1e9+7;
- const int base = 1e9;
- const int MAX = 1e5;
- const double EPS = 1e-9;
- const double PI = acos(-1.);
- #define int ll
- int a[100005];
- main()
- {
- sync;
- int t;
- cin>>t;
- for (int h=0;h<t;h++){
- map<int,int> cnt;
- int n,q, difCnt=0;
- cin>>n>>q;
- for (int i=0;i<n;i++){
- cin>>a[i];
- cnt[a[i]];
- cnt[a[i]]++;
- if (cnt[a[i]]==1)
- difCnt++;
- }
- for (int i=0;i<q;i++){
- int type;
- cin>>type;
- if (type==2) cout<<difCnt-(cnt[0]>0)<<endl;
- else{
- int p,v;
- cin>>p>>v;
- if (v!=a[p-1]){
- cnt[v];
- cnt[a[p-1]];
- if (cnt[a[p-1]]==1)
- difCnt--;
- if (cnt[v]==0)
- difCnt++;
- cnt[a[p-1]]--;
- cnt[v]++;
- a[p-1]=v;
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement