Pagini recente » Cod sursa (job #438104) | Cod sursa (job #2268571) | Ciorna | Cod sursa (job #2194587) | Cod sursa (job #1038096)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
vector <int>h[666013];
int n,val,tip;
int cauta(int x)
{
for(int i=0;i<h[x%666013].size();i++)
if(h[x%666013][i]==x)
return i;
return -1;
}
void insereaza(int x)
{
if(cauta(x)==-1)
h[x%666013].push_back(x);
}
void sterge(int x)
{
int y=cauta(x);
if(y!=-1)
{
h[x%666013][y]=h[x%666013][h[x%666013].size()-1];
h[x%666013].resize(h[x%666013].size()-1);
}
}
int main()
{
f>>n;
for(int i=1;i<=n;i++)
{
f>>tip>>val;
if(tip==1)
insereaza(val);
if(tip==2)
sterge(val);
if(tip==3)
{
if(cauta(val)!=-1)
g<<'1'<<endl;
else
g<<'0'<<endl;
}
}
f.close();
g.close();
return 0;
}