Pagini recente » Cod sursa (job #39575) | Cod sursa (job #746456) | Cod sursa (job #2197812) | Cod sursa (job #2838386) | Cod sursa (job #732221)
Cod sursa(job #732221)
#include <stdio.h>
#include <vector>
#define val 666013
using namespace std;
int n;
vector <int> mul[val];
inline vector<int>::iterator cautare(int x){
vector <int>::iterator it;
int pos = x % val;
for(it = mul[pos].begin(); it != mul[pos].end(); ++it)
if(*it == x)
return it;
return mul[pos].end();
}
inline void inserare(int x){
int pos = x % val;
if(cautare(x) == mul[pos].end())
mul[pos].push_back(x);
}
inline void stergere(int x){
int pos = x % val;
vector<int>::iterator it = cautare(x);
if (it != mul[pos].end())
mul[pos].erase(it);
}
int main(){
int operatie, x;
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
for(scanf("%d", &n); n; --n){
scanf("%d %d", &operatie, &x);
if(operatie == 1){
inserare(x);
continue;
}
if(operatie == 2){
stergere(x);
continue;
}
printf("%d\n", cautare(x) != mul[x % val].end());
}
return 0;
}