Pagini recente » Cod sursa (job #1764333) | Cod sursa (job #2971322) | Cod sursa (job #2481429) | Cod sursa (job #1157615) | Cod sursa (job #2243336)
#include <bits/stdc++.h>
using namespace std;
const int P=99991;
int n;
vector <int> h[P];
void adaug(int x);
void sterg(int x);
int caut(int x);
int main()
{int i,p,x;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
in>>n;
for (i=1;i<=n;i++)
{in>>p>>x;
if (p==1)
adaug(x);
if (p==2)
sterg(x);
if (p==3)
out<<caut(x)<<"\n";
}
}
void adaug(int x)
{
int r=x%P,i,gasit=0;
for (i=0;i<h[r].size()&&gasit==0;i++)
if (h[r][i]==x)
gasit=1;
if (gasit==0)
h[r].push_back(x);
}
void sterg(int x)
{
int r=x%P,i,gasit=0;
for (i=0;i<h[r].size()&&gasit==0;i++)
if (h[r][i]==x)
{
gasit=1;
h[r][i]=h[r][h[r].size()];
h[r].pop_back();
}
}
int caut(int x)
{
int r=x%P,i;
for (i=0;i<h[r].size();i++)
if (h[r][i]==x)
return 1;
return 0;
}