Pagini recente » Cod sursa (job #2322121) | Cod sursa (job #2468508) | Cod sursa (job #836650) | Cod sursa (job #1479429) | Cod sursa (job #1047146)
#include <vector>
#include <fstream>
using namespace std;
vector<int>H[666013];
int n,x,op;
ifstream fcin("hashuri.in");
ofstream fcout("hashuri.out");
int cauta(int val)
{
int i;
unsigned m=H[val%666013].size();
for(i=0;i<m;i++)
if(H[val%666013][i]==val)
return i;
return -1;
}
void inserare(int val)
{
if(cauta(val)==-1)
H[val%666013].push_back(val);
}
void stergere(int val)
{
int cine=cauta(val);
if(cine!=-1)
H[val%666013].erase(H[val%666013].begin()+cine);
}
void gasit(int val)
{
if(cauta(val)==-1)
fcout<<'0';
else
fcout<<'1';
fcout<<"\n";
}
int main()
{
fcin>>n;
for(int i=1;i<=n;i++)
{
fcin>>op>>x;
if(op==1)
inserare(x);
if(op==2)
stergere(x);
if(op==3)
gasit(x);
}
fcin.close();
fcout.close();
return 0;
}