Pagini recente » Cod sursa (job #3210106) | Cod sursa (job #496506) | Cod sursa (job #181104) | Cod sursa (job #1160397) | Cod sursa (job #1480863)
#include <iostream>
#include <cstdio>
#include <vector>
#include <iterator>
using namespace std;
const int MOD = 699967;
vector <int> v[MOD];
int N;
int H(int x)
{
return x % MOD;
}
void adauga(int x)
{
int p = H( x );
bool gasit = false;
for(vector <int>:: iterator it = v[ p ].begin(); it != v[ p ].end(); it++)
if( *it == x )
{
gasit = true;
break;
}
if( gasit == false )
v[ p ].push_back( x );
}
void sterge(int x)
{
int p = H( x );
for(vector <int>::iterator it = v[ p ].begin(); it != v[ p ].end(); it++)
if( *it == x )
{
v[ p ].erase( it );
return;
}
}
bool cauta(int x)
{
int p = H( x );
for(vector <int>:: iterator it = v[ p ].begin(); it != v[ p ].end(); it++)
if( *it == x )
return true;
return false;
}
int main()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d",&N);
int cod, x;
for(int i = 1; i <= N; i++)
{
scanf("%d %d",&cod,&x);
if( cod == 1 )
{
adauga( x );
continue;
}
if( cod == 2 )
{
sterge( x );
continue;
}
if( cod == 3 )
{
if( cauta( x ) == true )
printf("%d\n",1);
else printf("%d\n",0);
}
}
return 0;
}