Cod sursa(job #2356942)

Utilizator Andrei-27Arhire Andrei Andrei-27 Data 27 februarie 2019 00:09:09
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.08 kb
#include <bits/stdc++.h>
#define MOD 666013
using namespace std;
ifstream in ("hashuri.in") ;
ofstream out ("hashuri.out");
vector < int >  v [ MOD ] ;
vector < int > :: iterator find_value ( int x )
{
    vector < int > :: iterator it ;
    for ( it = v[ x % MOD ].begin() ; it != v [ x % MOD ].end() ; ++ it )
        if ( *it == x ) return it ;
    return v [ x % MOD ].end() ;


}
void push_x ( int x )
{
    vector < int > :: iterator it ;
   if ( find_value(x) == v[ x % MOD ].end() )
    v [ x % MOD ].push_back(x) ;
}
void erase_value ( int x )
{
    vector < int > :: iterator it ;
    it = find_value ( x ) ;
    if ( it != v [ x % MOD ].end() )
        v [ x % MOD ].erase (it) ;


}
int n , x , y ;
int main ()
{
   in >> n ;
   while ( n -- )
   {
       int x ;
       in >> x >> y ;
        if ( x == 1 )   push_x( y ) ;
        if ( x == 2 )   erase_value ( y ) ;
        if ( x == 3 )   if ( find_value( y ) == v [ y % MOD ].end() )   out << "0\n" ;
                        else                                            out << "1\n" ;
   }
}