Pagini recente » Cod sursa (job #600339) | Cod sursa (job #1242688) | Cod sursa (job #2954407) | Cod sursa (job #3139229) | Cod sursa (job #432189)
Cod sursa(job #432189)
#include <stdio.h>
#include <vector>
#define Mod 666013
#define pb push_back
using namespace std;
vector< int > G[Mod];
int n,i,op,x;
inline vector< int >:: iterator find(int x){
int unde=x%Mod;
vector< int >:: iterator it;
for(it=G[unde].begin(); it!=G[unde].end(); ++it)
if(*it == x ) return it;
return G[unde].end();
}
inline void adaug(int x){
int unde = x % Mod;
if( find(x) == G[unde].end() )
G[unde].pb(x);
}
inline void sterg(int x){
int unde = x % Mod;
vector< int >:: iterator poz=find(x);
if( poz != G[unde].end() )
G[unde].erase(poz);
}
int main(){
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d",&n);
for(i=1;i<=n;++i){
scanf("%d%d",&op,&x);
switch( op ){
case 1 : adaug(x); break;
case 2 : sterg(x); break;
case 3 : printf("%d\n", find(x % Mod) != G[x].end() ); break;
default : break;
}
}
fclose(stdin); fclose(stdout);
return 0;
}