Cod sursa(job #2570459)

Utilizator AlexPascu007Pascu Ionut Alexandru AlexPascu007 Data 4 martie 2020 16:56:44
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.9 kb
#include <bits/stdc++.h>
#define mod 1000017
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int x,n,cod,inhash;
vector<int> h[mod+3];
vector<int>::iterator it;
int main() {
    fin>>n;
    while (n--) {
        fin>>cod>>x;
        if (cod==1) {
            inhash=0;
            if (find(h[x%mod].begin(),h[x%mod].end(),x)!=h[x%mod].end())
                inhash=1;
            if (inhash==0)
                h[x%mod].push_back(x);
        }
        else if (cod==2) {
            for (it=h[x%mod].begin();it!=h[x%mod].end();it++)
                if (*it==x) {
                    h[x%mod].erase(it);
                    break;
                }
        }
        else {
            if (find(h[x%mod].begin(),h[x%mod].end(),x)!=h[x%mod].end())
                fout<<"1\n";
            else
                fout<<"0\n";
        }
    }
    return 0;
}