Pagini recente » Cod sursa (job #530823) | Cod sursa (job #2885002) | Cod sursa (job #1605603) | Cod sursa (job #257203) | Cod sursa (job #631659)
Cod sursa(job #631659)
#include <fstream>
#include <vector>
#define mod 666013
using namespace std;
vector <int> h[mod];
vector <int>:: iterator it;
int i,x,y,n,ind;
bool ok;
int main()
{
ifstream f("hashuri.in");
ofstream g("hashuri.out");
f>>n;
for (i=1;i<=n;i++) {
f>>x>>y;
ind=y%mod;
if (x==1) {
ok=true;
for (it=h[ind].begin();it!=h[ind].end();it++)
if (*it==y) {ok=false;break;}
if (ok==true) h[ind].push_back(y);
}
if (x==2) {
ok=true;
for (it=h[ind].begin();it!=h[ind].end();it++)
if (*it==y) {ok=false;break;}
if (ok==false) h[ind].erase(it);
}
if (x==3) {
ok=true;
for (it=h[ind].begin();it!=h[ind].end();it++)
if (*it==y) {g<<'1'<<'\n';ok=false;break;}
if (ok==true) g<<'0'<<'\n';
}
}
f.close();
g.close();
return 0;
}