Cod sursa(job #3130689)

Utilizator Serban09Baesu Serban Serban09 Data 18 mai 2023 13:57:16
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.88 kb
#include<iostream>
#include<fstream>
#include<vector>

using namespace std;
vector<int> h[666013];
ifstream f("hashuri.in");
ofstream g("hashuri.out");

int exista(vector<int> &h, int x)
{
    for(int i=0; i<h.size(); i++){
        if(h[i] == x)
            return 1;}
    return 0;
}

int main()
{
    int n, k, x;
    f>>n;
    for(int i=0; i<n; i++){
        f>>k>>x;
        switch(k){
            case 1:
                if(exista(h[x%666013], x) == 0)
                    h[x%666013].push_back(x);
                break;
            case 2:
                for(int i=0; i<h[x%666013].size(); i++)
                    if(h[x%666013][i] == x)
                        h[x%666013].erase(h[x%666013].begin() + i);
                break;
            case 3:
                g<<exista(h[x%666013], x)<<endl;
                break;
        }
    }
    return 0;
}