Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- unordered_map <int, int> val, freq;
- int main(){
- int Q;
- scanf("%d", &Q);
- for(int q=1;q<=Q;q++){
- int opr, x;
- scanf("%d %d", &opr, &x);
- if(opr == 3){
- if(freq[x] > 0) printf("1\n");
- else printf("0\n");
- }
- else if(opr == 1){
- if(freq[ val[x] ] > 0) freq[ val[x] ] --;
- val[x] ++;
- freq[ val[x] ] ++;
- }
- else{
- if(val[x] == 0) continue;
- if(freq[ val[x] ] > 0) freq[ val[x] ] --;
- val[x] --;
- freq[ val[x] ] ++;
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment