Pagini recente » Cod sursa (job #347819) | Cod sursa (job #2660036) | Cod sursa (job #2149922) | Cod sursa (job #1412896) | Cod sursa (job #2182530)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
const int MOD = 666013;
list < int > v[MOD];
inline bool Gasire(int x) {
int hashCode=x%MOD;
list<int>::iterator it;
for(it=v[hashCode].begin(); it!=v[hashCode].end(); it++)
if(*it==x)
return true;
return false;
}
inline void Inserare(int x) {
int hashCode=x%MOD;
if(!Gasire(x))
v[hashCode].push_back(x);
}
inline void Stergere(int x) {
int hashCode=x%MOD;
list<int>::iterator it;
for(it=v[hashCode].begin(); it!=v[hashCode].end(); it++)
if(*it==x) {
v[hashCode].erase(it);
return;
}
}
int main()
{
int n,op,x;
fin>>n;
while(n--) {
fin>>op>>x;
if(op==1)
Inserare(x);
if(op==2)
Stergere(x);
if(op==3)
fout<<Gasire(x)<<endl;
}
return 0;
}