Cod sursa(job #2772078)

Utilizator BlueLuca888Girbovan Robert Luca BlueLuca888 Data 30 august 2021 17:50:56
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.15 kb
#include <iostream>
#include <fstream>
#include <vector>
#define MOD 133733

using namespace std;

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

vector <int> h[MOD];
int qcnt, found;
int tip, x;

int main (){
    fin>>qcnt;
    for(int query=1; query<=qcnt; query++){
        fin>>tip>>x;
        if(tip == 1){
            found=0;
            for(int i=0; i<h[x%MOD].size(); i++)
                if(h[x%MOD][i] == x){
                    found=1;
                    break;
                }
            if(found == 0)
                h[x%MOD].push_back(x);
        }else if(tip == 2){
            found=-1;
            for(int i=0; i<h[x%MOD].size(); i++)
                if(h[x%MOD][i] == x){
                    found=i;
                    break;
                }
            if(found != -1)
                h[x%MOD].erase(h[x%MOD].begin() + found);
        }else{
            found=0;
            for(int i=0; i<h[x%MOD].size(); i++)
                if(h[x%MOD][i] == x){
                    found=1;
                    break;
                }
            fout<<found<<"\n";
        }
    }
    return 0;
}