Cod sursa(job #2622424)

Utilizator grecuGrecu Cristian grecu Data 1 iunie 2020 12:10:05
Problema Hashuri Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.98 kb
#include <bits/stdc++.h>

using namespace std;

const int mod = 666666;
vector<int> hasht[mod];
ifstream f("hashuri.in");
ofstream g("hashuri.out");


void add(int x){

    hasht[m].push_back(x);
}

void deleteh(int x){
    int m = x % mod;
    for (int i = 0; i < hasht[m].size(); i++){
        if(hasht[m][i] == x){
            hasht[m].erase(hasht[m].begin()+i);
            return;
        }
    }
}

int searchh(int x){
    int m = x % mod;
    for (int i = 0; i < hasht[m].size(); i++){
        if(hasht[m][i] == x){
            return 1;
        }
    }
    return 0;
}


int main()
{
    int n, x, y;
    f>>n;
    for(int i = 0; i < n; i++){
        f >> x >> y;
        switch(x){
            case 1:
                add(y);
                break;
            case 2:
                deleteh(y);
                break;
            case 3:
                g << searchh(y) << endl;
                break;

        }
    }
    return 0;
}