Cod sursa(job #2524594)

Utilizator AlexPascu007Pascu Ionut Alexandru AlexPascu007 Data 15 ianuarie 2020 21:50:25
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.91 kb
#include <bits/stdc++.h>
#define mod 1000017
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int n,x,tip,poz,inhash;
vector<int> h[mod];
vector<int>::iterator it;
int main() {
    fin>>n;
    while (n--) {
        fin>>tip>>x;
        if (tip==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);
        }
        if (tip==2) {
            for (it=h[x%mod].begin();it!=h[x%mod].end();it++)
                if (*it==x) {
                    h[x%mod].erase(it);
                    break;
                }
        }
        if (tip==3) {
            inhash=0;
            if (find(h[x%mod].begin(),h[x%mod].end(),x)!=h[x%mod].end())
                inhash=1;
            fout<<inhash<<"\n";
        }
    }
    return 0;
}