Pagini recente » Cod sursa (job #3180487) | Cod sursa (job #1099662) | Cod sursa (job #2420507) | Cod sursa (job #591167) | Cod sursa (job #1604665)
#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 poz;
inline void Add(const int &x)
{
vector <int> :: iterator it;
for(it=h[poz].begin(); it!=h[poz].end(); it++)
if(*it==x) return;
h[poz].push_back(x);
}
inline void Delete(const int &x)
{
vector <int> :: iterator it;
for(it=h[poz].begin(); it!=h[poz].end(); it++)
if(*it==x)
{
h[poz].erase(it);
return;
}
}
inline bool Exist(const int &x)
{
vector <int> :: iterator it;
for(it=h[poz].begin(); it!=h[poz].end(); it++)
if(*it==x) 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;
poz=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;
}