Cod sursa(job #2523800)

Utilizator radugheoRadu Mihai Gheorghe radugheo Data 14 ianuarie 2020 19:11:17
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.16 kb
#include <bits/stdc++.h>
#define MOD 100003

using namespace std;

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

int n, t, x, ok;

vector <int> hes[MOD];
vector <int> :: iterator it;

int main(){
    fin >> n;
    for (int i=1; i<=n; i++){
        fin >> t >> x;
        if (t == 1){
            ok = 0;
            for (int t=0; t<hes[x%MOD].size(); t++){
                if (hes[x%MOD][t] == x){
                    ok = 1;
                    break;
                }
            }
            if (ok == 0){
                hes[x%MOD].push_back(x);
            }
        }
        if (t == 2){
            ok = 0;
            for (it = hes[x%MOD].begin(); it != hes[x%MOD].end(); it++){
                if (*it == x){
                    hes[x%MOD].erase (it);
                    break;
                }
            }
        }
        if (t == 3){
            ok = 0;
            for (int t=0; t<hes[x%MOD].size(); t++){
                if (hes[x%MOD][t] == x){
                    ok = 1;
                    break;
                }
            }
            fout << ok << "\n";
        }
    }
    return 0;
}