Cod sursa(job #1946617)

Utilizator waren4Marius Radu waren4 Data 30 martie 2017 11:46:20
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 1.13 kb
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

const int Mod = 666013;

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

vector <int> Hash[Mod];

int n;

int main() {
    int i,c,j,x;
    f>>n;
    for(i = 1; i <= n; ++i) {
        f>>c>>x;
        if(c == 1) {
            bool 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) {
            bool ok = 0;
            for(j = 0; j < Hash[x%Mod].size(); ++j) {
                if(x == Hash[x%Mod][j]) {
                    ok = 1;
                    break;
                }
            }
            g<<ok<<'\n';
        }
    }
    return 0;
}