Pagini recente » Cod sursa (job #2165789) | Cod sursa (job #2936648) | Cod sursa (job #2458788) | Cod sursa (job #547184) | Cod sursa (job #2896430)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
#define mod 786433
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int n;
vector <int> h[mod];
int cauta( int x )
{
int n = h[ x % mod ].size();
for( int i = 0; i < n; ++i )
if( x == h[ x % mod ][i] )
return i;
return -1;
}
void adauga( int x )
{
h[ x % mod ].push_back( x );
}
void sterge( int x )
{
if( cauta( x ) != -1 )
h[ x % mod ].erase( h[ x % mod ].begin() + cauta( x ) );
}
int main()
{
f >> n;
for( int i = 0; i < n; ++i )
{
int x, y;
f >> x >> y;
if( x == 1 )
adauga( y );
else if( x == 2 )
sterge( y );
else
g << ( cauta( y ) != -1 ? 1 : 0 ) << "\n";
}
f.close();
g.close();
return 0;
}