Pagini recente » Cod sursa (job #1049098) | Cod sursa (job #19890) | Cod sursa (job #407841) | Cod sursa (job #1968047) | Cod sursa (job #1026314)
#include<iostream>
#include<vector>
#include<fstream>
#define MOD 666031
using namespace std;
vector <int>h[666031];
ofstream g( "hashuri.out");
bool find(int x)
{
int j = x % MOD;
for( vector <int>::iterator it = h[j].begin(); it != h[j].end(); it++)
if(*it == x)
return true;
return false;
}
void adaugare(int x)
{
if( find( x) == false)
h[x % MOD].push_back( x);
}
void stergere(int x)
{
vector<int>::iterator it;
int j = x % MOD, ok=0;
for(it=h[j].begin(); it!=h[j].end() && ok == 0; it++ )
if(*it == x)
{
h[j].erase(it);
ok = 1;
}
}
void gasire(int x)
{
if( find( x) == true)
g<<'1';
else
g<<'0';
g<<"\n";
}
int main()
{
long long n, i, x, y ;
ifstream f( "hashuri.in");
f >> n;
for(i = 0; i < n; i ++)
{
f >> x >> y;
if( x == 1)
adaugare( y);
if( x == 2)
stergere( y);
if( x == 3)
gasire( y);
}
}