Pagini recente » Cod sursa (job #2325058) | Cod sursa (job #496978) | Cod sursa (job #972895) | Cod sursa (job #553707) | Cod sursa (job #2918093)
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
using namespace std;
ifstream fin ("hashuri.in");
ofstream fout ("hashuri.out");
int n, type, x;
const int MOD = 666317;
vector <pair<int, int>> map_hash[MOD];
inline int new_hash(const int x){
return x % MOD;
}
inline void add_hash(const int x){
int y = new_hash(x);
bool found = false;
for(int i=0; i < (int)map_hash[y].size(); i++)
if(map_hash[y][i].first == x){
map_hash[y][i].second++;
found = true;
}
if(!found)
map_hash[y].push_back({x, 1});
}
inline void remove_hash(const int x){
int y = new_hash(x);
for(int i=0; i < (int)map_hash[y].size(); i++)
if(map_hash[y][i].first == x && map_hash[y][i].second)
map_hash[y][i].second--;
}
inline bool query_hash(const int x){
int y = new_hash(x);
for(int i=0; i < (int)map_hash[y].size(); i++)
if(map_hash[y][i].first == x && map_hash[y][i].second)
return true;
return false;
}
int main (){
ios_base::sync_with_stdio(false);
fin.tie(nullptr), fout.tie(nullptr);
fin>>n;
while(n--){
fin>>type>>x;
if(type == 1){
add_hash(x);
}else if(type == 2){
remove_hash(x);
}else{
fout<<query_hash(x)<<"\n";
}
}
return 0;
}