Pagini recente » Cod sursa (job #814476) | Cod sursa (job #3230700) | Cod sursa (job #2689999) | Cod sursa (job #154207) | Cod sursa (job #629323)
Cod sursa(job #629323)
#include <fstream>
#include <vector>
#include <algorithm>
#define MOD 666013
#define pb push_back
using namespace std;
vector< int > H[MOD];
int op, x, N;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
inline void Add( int pos, int val )
{
for( vector< int >::iterator it = H[ pos ].begin(); it != H[ pos ].end(); ++it )
if( *it == val ) return;
H[ pos ].pb( val );
}
inline void Remove( int pos, int val )
{
for( vector< int >::iterator it = H[ pos ].begin(); it != H[ pos ].end(); ++it )
if( *it == val )
{
swap( *it, *( H[ pos ].end() - 1 ) );
H[ pos ].pop_back();
return;
}
}
inline int Q( int pos, int val )
{
for( vector< int >::iterator it = H[ pos ].begin(); it != H[ pos ].end(); ++it )
if( *it == val ) return 1;
return 0;
}
int main()
{
in >> N;
while( N-- )
{
in >> op >> x;
switch( op )
{
case 1:
Add( x%MOD, x );
break;
case 2:
Remove( x%MOD, x );
break;
case 3:
out << Q( x%MOD, x ) << '\n';
break;
}
}
return 0;
}