Pagini recente » Cod sursa (job #962432) | Cod sursa (job #2290762) | Cod sursa (job #1159143) | Cod sursa (job #1887203) | Cod sursa (job #2268207)
#include <bits/stdc++.h>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
const int N = 100003; /// un numar prim utilizat in tabela de dispersie ( tabela hash )
vector<int> H[N];
vector<int>::iterator it;
int n,o,x,h;
int main()
{
f>>n;
for(;n;n--)
{
f>>o>>x;
h=x%N;
for(it=H[h].begin();it!=H[h].end();it++)
if(*it==x)
break;
if(o==1&&it==H[h].end())
H[h].push_back(x);
else if(o==2&&it!=H[h].end())
{
*it=H[h].back();
H[h].pop_back();
}
else if(o==3)
{
if(it==H[h].end())
g<<"0\n";
else
g<<"1\n";
}
}
return 0;
}