Pagini recente » Cod sursa (job #111351) | Cod sursa (job #1526261) | Cod sursa (job #321556) | Cod sursa (job #1031034) | Cod sursa (job #251126)
Cod sursa(job #251126)
#include<stdio.h>
#include<vector>
#define MOD 666013
using namespace std;
vector< int >H[MOD];
inline bool find( const int val )
{
int pos=val%MOD;
vector< int >::iterator it;
for(it=H[pos].begin(); it!=H[pos].end(); ++it)
if( *it==val )
return 1;
return 0;
}
inline void erase( const int val )
{
int pos=val%MOD;
vector< int >::iterator it;
for(it=H[pos].begin(); it!=H[pos].end(); ++it)
if( *it==val )
{
H[pos].erase(it);
break;
}
}
inline void insert( const int val )
{
int pos=val%MOD;
if( !find( val ) )
H[ pos ].push_back( val );
}
int main()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
int T;
scanf("%d",&T);
int a1,a2;
while( T-- )
{
scanf("%d%d",&a1,&a2);
if( a1==1 )
insert( a2 );
if( a1==2 )
erase( a2 );
if( a1==3 )
printf("%d\n",find(a2));
}
return 0;
}//foarte elegant :)