Cod sursa(job #2896486)

Utilizator RaresParleaParlea Costin-Rares-Calin RaresParlea Data 29 aprilie 2022 23:25:25
Problema Hashuri Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.82 kb
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
vector<int>Hash[666000];
int main(){
    int k=666000,N,op,e,c,i,j;
    bool gasit=false;
    fin>>N;
    for(i=0;i<N;i++){
        fin>>op>>e;
        c=e%k;
        for(j=0;j<Hash[c].size();j++)
            if(Hash[c][j]==e){
                gasit=true;
                break;
            }

        if(op==1)
            if(!gasit)
                Hash[c].push_back(e);
        else if(op==2)
            if(gasit){
                swap(Hash[c][j],Hash[c].back());
                Hash[c].pop_back();
            }
        else if(gasit)
            fout<<1<<endl;;
        else
            fout<<0<<endl;

    }
    f.close();
    g.close();
    return 0;
}