Cod sursa(job #2878930)

Utilizator daristyleBejan Darius-Ramon daristyle Data 28 martie 2022 10:14:59
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.93 kb
#include <bits/stdc++.h>

using namespace std;

const int modulo=666013;
list<int> l[modulo];
int rest;
void op1(int n){
    rest=n%modulo;
    l[rest].push_back(n);
}
list<int>::iterator x;
void op2(int n){
    rest=n%modulo;

    for(x=l[rest].begin(); x!=l[rest].end(); ++x)
        if(*x==n){
            l[rest].erase(x);
            break;
        }
}

bool op3(int n){
    rest=n%modulo;
    for(x=l[rest].begin(); x!=l[rest].end(); ++x)
        if(*x==n)    return 1;
    return 0;
}

int main()
{
    ifstream fin("hashuri.in");
    ofstream fout("hashuri.out");
    int nrop, op, nr;
    fin>>nrop;
    for(int i=1; i<=nrop; ++i){
        fin>>op>>nr;
        switch(op){
            case 1: if(!op3(nr)) op1(nr);
                    break;
            case 2: op2(nr);
                    break;
            case 3: fout<<op3(nr)<<'\n';
                    break;
        }
    }
    return 0;
}