Pagini recente » Cod sursa (job #2714634) | Cod sursa (job #1717283) | Cod sursa (job #2645187) | Cod sursa (job #494761) | Cod sursa (job #1334312)
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#include <fstream>
#define m 666013
using namespace std;
int n,tip,x;
vector<int> H[m];
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int find(int x)
{
int hash=x%m,j;
for(j=0;j<H[hash].size();j++)
if(H[hash][j]==x) return j;
return j;
}
void erase(int x)
{
int hash=x%m;
vector<int>::iterator it;
for(it=H[hash].begin();it!=H[hash].end();++it)
if (*it == x) {H[hash].erase(it);return;}
}
void insert(int x)
{
int hash=x%m;
if(find(x)==H[hash].size())
H[hash].push_back(x);
}
int main()
{
fin>>n;
for(int i=1;i<=n;i++)
{
fin>>tip>>x;
int hash=x%m;
if(tip==1) insert(x);
else if(tip==2) erase(x);
else
{
if(find(x)!=H[hash].size()) fout<<1<<"\n";
else fout<<0<<"\n";
}
}
}