Cod sursa(job #1920900)

Utilizator paunmatei7FMI Paun Matei paunmatei7 Data 10 martie 2017 10:35:21
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 1.29 kb
#include <fstream>
#include <vector>

using namespace std;

const int Mod = 666013;

ifstream cin("hashuri.in");
ofstream cout("hashuri.out");

vector < int > Hash[Mod];

int main() {
    int n = 0;
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        int type = 0, x = 0;
        cin >> type >> x;
        if(type == 1) {
            int ok = 0;
            for(vector < int > :: iterator it = Hash[x % Mod].begin(); it != Hash[x % Mod].end(); ++it) {
                if(*it == x) {
                     ok = 1;
                     break;
                }
            }
            if(ok == 0) {
                Hash[x % Mod].push_back(x);
            }
        }
        if(type == 2) {
            for(vector < int > :: iterator it = Hash[x % Mod].begin(); it != Hash[x % Mod].end(); ++it) {
                if(*it == x) {
                    *it = -1;
                    break;
                }
            }
        }
        if(type == 3) {
            int ok = 0;
            for(vector < int > :: iterator it = Hash[x % Mod].begin(); it != Hash[x % Mod].end(); ++it) {
                if(*it == x) {
                     ok = 1;
                     break;
                }
            }
            cout << ok << "\n";
        }
    }
    return 0;
}