Pagini recente » Cod sursa (job #1614479) | Cod sursa (job #846390) | Cod sursa (job #2888227) | Cod sursa (job #106557) | Cod sursa (job #1476156)
#include <stdio.h>
#include <vector>
#define mod 100313
using namespace std;
int tip,x,i,n;
vector <int> g[mod+5];
void insert_hash(int x)
{
unsigned int i; int y=x%mod;
for (i=0;i<g[y].size();i++)
if (g[y][i]==x) return;
g[y].push_back(x);
}
void delete_hash(int x)
{
unsigned int i; int y=x%mod;
for (i=0;i<g[y].size();i++)
if (g[y][i]==x) { g[y].erase(g[y].begin()+i); return; }
}
bool inhash(int x)
{
unsigned int i; int y=x%mod;
for (i=0;i<g[y].size();i++)
if (g[y][i]==x) return true;
return false;
}
int main() {
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d",&n);
for (i=1;i<=n;i++) {
scanf("%d %d",&tip,&x);
if (tip==1) insert_hash(x); else
if (tip==2) delete_hash(x); else
{
if (inhash(x)) puts("1"); else puts("0");
}
}
return 0;
}