Cod sursa(job #1344834)

Utilizator StarGold2Emanuel Nrx StarGold2 Data 16 februarie 2015 23:57:08
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.93 kb
#include <fstream>
#include  <vector>
#define DIM 999013
using namespace std;

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

int n, m, i, j, k, ok, minim, t, x, y, z, val;
vector<int>::iterator it; vector<int> v[DIM];
vector<int>::iterator position(int x, int y){
    vector<int>::iterator it;
    for(it = v[y].begin(); it < v[y].end(); it++){
        if(x == *it){
            return it;
        }
    }
    return it;
}

int main(){
    fin >> n;
    for(i = 1; i <= n; i++){
        fin >> t >> x;
        it = position(x, x % DIM);
        if(t == 1)
            if(it == v[x % DIM].end())
                v[x%DIM].push_back(x);
        if(t == 2)
            if(it != v[x % DIM].end())
                v[x%DIM].erase(it);
        if(t == 3){
            if(it != v[x % DIM].end())
                fout << "1\n";
            else
                fout << "0\n";
        }
    }
    return 0;
}