Pagini recente » Cod sursa (job #1151830) | Cod sursa (job #1640947) | Cod sursa (job #679963) | Cod sursa (job #2024088) | Cod sursa (job #1144247)
#include<fstream>
#include<vector>
using namespace std;
ifstream fin( "hashuri.in" );
ofstream fout( "hashuri.out" );
const int mod = 666013;
vector <int> h[ mod ];
int main()
{
int p, x, n, key, j;
bool ok;
fin>>n;
for( int i = 0; i < n; ++ i ) {
ok = 0;
fin>>p>>x;
key = x % mod;
for( j = 0; j < (int)h[ key ].size(); ++ j ) {
if ( h[ key ][ j ] == x ) {
ok = 1;
break;
}
}
if ( p == 1 ) {
if ( ok == 0 ) {
h[ key ].push_back( x );
}
} else if ( p == 2 ) {
if ( ok == 1 ) {
h[ key ][ j ] = h[ key ][ h[key].size() - 1 ];
h[ key ].resize( h[key].size() - 1 );
}
} else if ( p == 3 ) {
fout<<ok<<'\n';
}
}
fin.close();
fout.close();
return 0;
}