Cod sursa(job #1969417)

Utilizator waren4Marius Radu waren4 Data 18 aprilie 2017 14:15:20
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 1.3 kb
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>

using namespace std;

ifstream f("hashuri.in"); ofstream g("hashuri.out");

const int Mod = 666013;

vector <int> Hash[Mod];

int n, c, x;

int main() {
    int i;
    f>>n;
    for(i = 1; i <= n; ++i) {
        bool ok;
        int j;
        f>>c>>x;
        if (c == 1) {
            ok = 1;
            for(j = 0; j < Hash[x % Mod].size(); ++j) {
                if (x == Hash[x % Mod][j]) {
                    ok = 0;
                    break;
                }
            }
            if (ok) {
                Hash[x % Mod].push_back(x);
            }
        }
        if (c == 2) {
            for(j = 0; j < Hash[x % Mod].size(); ++j) {
                if (x == Hash[x % Mod][j]) {
                    Hash[x % Mod][j] = 0;
                    break;
                }
            }
        }
        if (c == 3) {
            ok = 0;
            for(j = 0; j < Hash[x % Mod].size(); ++j) {
                if (x == Hash[x % Mod][j]) {
                    ok = 1;
                    break;
                }
            }
            if (ok) {
                g<<1<<'\n';
            }
            else {
                g<<0<<'\n';
            }
        }
    }
    return 0;
}