Pagini recente » Cod sursa (job #2219869) | Cod sursa (job #2814947) | Cod sursa (job #1250632) | Cod sursa (job #1649707) | Cod sursa (job #1038048)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
vector <int>h[666013];
int cauta(vector<int>h[666013],int x)
{
int unde=x%666013;
for(int i=0;i<(unsigned)h[unde].size();i++)
if(h[unde][i]==x)
return 1;
return 0;
}
int insereaza(vector<int>&h[666013],int x)
{
if(cauta(h,x)>0)
return 0;
h[x%666013].push_back(x);
}
int sterge(vector<int>&h[666013],int x)
{
int y=cauta(h,x);
if(y==-1)
return 0;
h[x%666013][y]=h[x%666013].back();
h[x%666013].pop_back();
}
int main()
{
long long n,i,val;
int tip;
f>>n;
for(i=1;i<=n;i++)
{
f>>tip>>val;
if(tip==1)
g<<cauta(h,val)<<endl;
if(tip==2)
insereaza(h,val);
if(tip==3)
sterge(h,val);
}
f.close();
g.close();
return 0;
}