Pagini recente » Cod sursa (job #1542619) | Cod sursa (job #3248098) | Cod sursa (job #2634753) | Cod sursa (job #3226650) | Cod sursa (job #3149107)
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#pragma GCC target ("popcnt")
using namespace std;
ifstream fin ("hashuri.in");
ofstream fout ("hashuri.out");
const int MAX_N = 1'000'000;
const int LIM = 2'000'000'000;
const int MOD = 7919;
int n, t, x;
int xhash;
bool found;
vector<pair<int, bool>> h[MOD];
static inline void add(){
xhash = x % MOD;
found = false;
for(auto p : h[xhash]){
if(p.first == x){
found = true;
p.second = true;
break;
}
}
if(!found)
h[xhash].push_back({x, true});
}
static inline void rem(){
xhash = x % MOD;
for(auto &p : h[xhash]){
if(p.first == x){
p.second = false;
break;
}
}
}
static inline bool query(){
xhash = x % MOD;
found = false;
for(auto p : h[xhash]){
if(p.first == x){
if(p.second == true)
found = true;
break;
}
}
return found;
}
int main (){
ios_base::sync_with_stdio(false);
fin.tie(nullptr), fout.tie(nullptr);
fin>>n;
while(n--){
fin>>t>>x;
if(t == 1){ ///update add
add();
}else if(t == 2){ ///update remove
rem();
}else{ ///query
fout<<query()<<"\n";
}
}
return 0;
}