Cod sursa(job #1211361)

Utilizator mariusn01Marius Nicoli mariusn01 Data 22 iulie 2014 14:39:14
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 1.05 kb
#include <fstream>
#include <vector>

#define MOD 899919

using namespace std;

vector<int> H[MOD];
vector<int>::iterator it;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");

int n, i, x, t;

int main() {
    fin>>n;
    for (;n--;) {
        fin>>t>>x;
        i = x%MOD;
        if (t == 1) {

            for (it = H[i].begin();it!=H[i].end();it++) {
                if (*it == x)
                    break;
            }
            if (it == H[i].end())
                H[i].push_back(x);
            continue;
        }
        if (t == 2) {
            i = x%MOD;
            for (it = H[i].begin();it!=H[i].end();it++) {
                if (*it == x) {
                    H[i].erase(it);
                    break;
                }
            }
            continue;
        }
        if (t == 3) {
            for (it = H[i].begin();it!=H[i].end();it++) {
                if (*it == x)
                    break;
            }
            fout<<(H[i].end() != it)<<"\n";
        }
    }

    return 0;
}