Cod sursa(job #1072148)

Utilizator Athena99Anghel Anca Athena99 Data 4 ianuarie 2014 00:23:15
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.77 kb
#include <algorithm>
#include <fstream>
#include <vector>

using namespace std;

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

const int mod= 6613;

vector <int> v[mod];

int check( int x ) {
    int ch= 0;
    for ( vector <int>::iterator it= v[x%mod].begin(); it!=v[x%mod].end(); ++it ) {
        if ( *it==x ) {
            ch= 1;
            break;
        }
    }

    return ch;
}

int main(  ) {
    int n;
    fin>>n;
    for ( ; n>0; --n ) {
        int x, y;
        fin>>x>>y;
        if ( x==1 && check(y)==0 ) {
            v[y%mod].push_back(y);
        } else if ( x==2 && check(y)==1 ) {
            v[y%mod].erase( find( v[y%mod].begin(), v[y%mod].end(), y ) );
        } else if ( x==3 ) {
            fout<<check(y)<<"\n";
        }
    }

    return 0;
}