Pagini recente » Cod sursa (job #2480380) | Cod sursa (job #1939954) | Cod sursa (job #1425142) | Cod sursa (job #1749788) | Cod sursa (job #1604671)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream fin ("hashuri.in");
ofstream fout ("hashuri.out");
const int mod = 666013;
vector <int> h[mod];
int key;
vector <int> :: iterator Find(const int &x)
{
vector <int> :: iterator it;
for(it=h[key].begin(); it!=h[key].end(); it++)
if(*it==x) return it;
return h[key].end();
}
inline void Add(const int &x)
{
if(Find(x)==h[key].end())
h[key].push_back(x);
}
inline void Delete(const int &x)
{
vector <int> :: iterator it;
it=Find(x);
if(it!=h[key].end())
h[key].erase(it);
}
inline bool Exist(const int &x)
{
if(Find(x)!=h[key].end()) return true;
return false;
}
int main()
{
ios_base::sync_with_stdio(false);
int n, op, i, x, poz;
fin >> n;
for(i=1; i<=n; i++)
{
fin >> op >> x;
key=x%mod;
if(op==1) Add(x);
if(op==2) Delete(x);
if(op==3) fout << Exist(x) << "\n";
}
fin.close();
fout.close();
return 0;
}