Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- map<int, int> mp, fq;
- int main(){
- int Q;
- scanf("%d", &Q);
- while(Q--){
- int cmd, x;
- scanf("%d%d", &cmd, &x);
- if(cmd == 1){
- int f = mp[x]++;
- if(fq[f] > 0){
- --fq[f];
- }
- ++fq[f + 1];
- } else if(cmd == 2){
- if(mp[x] == 0){
- continue;
- }
- int f = mp[x]--;
- --fq[f];
- ++fq[f - 1];
- } else if(cmd == 3){
- if(fq[x] == 0){
- cout << "0\n";
- } else {
- cout << "1\n";
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement