Pagini recente » Cod sursa (job #233989) | Cod sursa (job #1666831) | Cod sursa (job #1115589) | Cod sursa (job #1844403) | Cod sursa (job #2739987)
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <cstring>
using namespace std;
int hash0( int x, int n){
return x % n;
}
void operatie_1 ( int x, vector < int > & v ){
int i = 0, ok = 1;
while( i < v.size() && ok==1 ){
if( v[i] == x ){
ok = 0;
}
i++;
}
if( ok ==1 ) v.push_back( x );
}
void operatie_2 ( int x, vector < int > & v ){
int i = 0, ok = 1 ;
while ( i < v.size() && ok == 1 ){
if ( v[i] == x ){
v[i] = v[ v.size() - 1 ];
v.pop_back();
ok = 0;
}
i++;
}
}
int operatie_3 ( int x, vector < int > v ){
int i = 0 , ok = 1 ;
while ( i < v.size() && ok == 1 ){
if ( v[i] == x ){
ok = 0;
}
i++;
}
if ( ok == 0 ) return 1;
else return 0;
}
int main(){
vector < vector < int > > v;
ifstream fin ( "hashuri.in" );
ofstream fout( "hashuri.out" );
int operatie, numar, n;
int constanta = 6703;
fin >> n;
for ( int i = 0; i < constanta; i++ ){
vector < int > v1;
v.push_back( v1 );
}
for( int i = 0; i < n; i ++ ){
fin >> operatie;
fin >> numar;
if ( operatie == 1 ) operatie_1 ( numar , v [ hash0 ( numar , constanta ) ] );
if ( operatie == 2 ) operatie_2 ( numar , v [ hash0 ( numar , constanta ) ] );
if ( operatie == 3 ) fout << operatie_3 ( numar , v [ hash0 ( numar , constanta ) ] ) << endl ;
}
}