Pagini recente » Cod sursa (job #2746562) | Cod sursa (job #635282) | Cod sursa (job #2750402) | Cod sursa (job #2618363) | Cod sursa (job #2745785)
#include <vector>
#include <iostream>
#include <cstring>
#include <fstream>
using namespace std;
int numar_prim = 666013;
void operatie_1( vector < int > &tabel_hash, int numar ){
if( tabel_hash[numar%numar_prim] != numar ){
tabel_hash[numar%numar_prim] = numar;
}
}
void operatie_2( vector < int > &tabel_hash, int numar ){
if( tabel_hash[numar%numar_prim] == numar ){
tabel_hash[numar%numar_prim] = numar_prim;
}
}
int operatie_3( vector < int > &tabel_hash, int numar ){
if( tabel_hash[numar%numar_prim] == numar ) return 1;
else return 0;
}
int main(){
vector < int > tabel_hash;
ifstream fin( "hashuri.in" );
ofstream fout( "hashuri.out" );
int n;
fin >> n;
for( int i = 0; i < numar_prim; i++ ){
tabel_hash.push_back( numar_prim );
}
for( int i = 0; i < n; i++ ){
int operatie, numar;
fin >> operatie >> numar;
if( operatie == 1 ) operatie_1( tabel_hash, numar );
if( operatie == 2 ) operatie_2( tabel_hash, numar );
if( operatie == 3 ) fout << operatie_3( tabel_hash, numar ) << endl;
}
}