Pagini recente » Cod sursa (job #1676837) | Cod sursa (job #1912681) | Cod sursa (job #780345) | Cod sursa (job #809485) | Cod sursa (job #1604634)
#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];
vector <int> :: iterator ok(int val, int poz)
{
vector <int> :: iterator it;
for(it=h[poz].begin(); it!=h[poz].end(); it++)
if(*it==val) return it;
return it;
}
void add(int val, int poz)
{
if(ok(val, poz)==h[poz].end())
h[poz].push_back(val);
}
void del(int val, int poz)
{
vector <int> :: iterator it=ok(val, poz);
if(it!=h[poz].end())
h[poz].erase(it);
}
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, poz);
if(op==2) del(x, poz);
if(op==3)
{
if(ok(x, poz)!=h[poz].end()) fout << "1\n";
else fout << "0\n";
}
}
fin.close();
fout.close();
return 0;
}