Cod sursa(job #2088309)

Utilizator liviu2000Dragomirescu Liviu liviu2000 Data 14 decembrie 2017 22:34:45
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 1.13 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin ("hashuri.in") ;
ofstream fout("hashuri.out") ;

vector<int> t[666014] ;

int main()
{
    int n , i , x , tp , y , j;
    bool rez ;
    fin >> n ;
    for ( int i = 1 ; i <= n ; i++ )
    {
        fin >> tp >> x ;
        rez = false ;
        if ( tp == 1 )
        {
            y = x % 666013 ;
            for ( j = 0 ; j < t[y].size() ; j++ )
                if ( t[y][j] == x )
                    rez = true ;
            if ( rez == false )
                t[y].push_back(x) ;
        }
        else if ( tp == 2 )
        {
            y = x % 666013 ;
            for ( j = 0 ; j < t[y].size() ; j++ )
                if ( x == t[y][j] )
                    t[y].erase(t[y].begin()+j,t[y].begin()+j+1) ;
        }
        else if ( tp == 3 )
        {
            y = x % 666013 ;
            for ( j = 0 ; j < t[y].size() ; j++ )
                if ( t[y][j] == x )
                    rez = true ;
            if ( rez == true )
                fout <<"1" << '\n' ;
            else
                fout <<"0" << '\n' ;
        }
    }
}