Pagini recente » Cod sursa (job #2592383) | Cod sursa (job #1195615) | Cod sursa (job #823457) | Cod sursa (job #482710) | Cod sursa (job #2182526)
#include <iostream>
#include <fstream>
#include <list>
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);
else if(op==2)
Stergere(x);
else fout<<Gasire(x)<<endl;
}
return 0;
}