Pagini recente » Cod sursa (job #1917690) | Cod sursa (job #3285941) | Cod sursa (job #2456240) | Cod sursa (job #1048980) | Cod sursa (job #1119962)
#include <stdio.h>
#include <set>
using namespace std;
#define N_MAX 1000000
#define modP 150001
#define mulQ 20011
set< int > htable[ modP ];
int hash( long long x ) {
return ( x * mulQ ) % modP;
}
void add( long long x ) {
int h = hash( x );
htable[ h ].insert( x );
}
void rem( long long x ) {
int h = hash( x );
htable[ h ].erase( x );
}
int ask( long long x ) {
int h = hash( x );
return htable[ h ].count( x ) == 1;
}
int main( ) {
FILE * fin, * fout;
fin = fopen( "hashuri.in", "r" );
fout = fopen( "hashuri.out", "w" );
int N;
fscanf( fin, "%d", &N );
int i;
for( i = 1; i <= N; i ++ ) {
int tp;
long long x;
fscanf( fin, "%d%lld", &tp, &x );
if( tp == 1 ) {
add( x );
} else if( tp == 2 ) {
rem( x );
} else {
fprintf( fout, "%d\n", ask( x ) );
}
}
fclose( fin );
fclose( fout );
}