Cod sursa(job #2976772)

Utilizator gabriel.9619Gabriel Stefan Tita gabriel.9619 Data 9 februarie 2023 23:12:08
Problema Hashuri Scor 30
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.06 kb
#include <fstream>
#include <vector>
#define mod 987654
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");

vector <int> l[mod];
vector <int>::iterator it;

int main()
{
    int n, t, x, i;
    fin>>n;
    while(n)
    {
        n--;
        fin>>t>>x;
        int poz=x%mod;
        if(t==1)
        {
            l[poz].push_back(x);
        }
        else
        if(t==2)
        {
            for(it=l[poz].begin();it!=l[poz].end();)
            {
                if(*it==x)
                {
                    it=l[poz].erase(it);
                }
            }
        }
        else
        {
            int ok=0;
            for(it=l[poz].begin();it!=l[poz].end();)
            {
                if(*it==x)
                {
                    ok=1;
                    break;
                }
            }
            if(ok==1)
            {
                fout<<1<<"\n";
            }
            else
            {
                fout<<0<<"\n";
            }
        }
    }
}