Cod sursa(job #2750557)

Utilizator proflaurianPanaete Adrian proflaurian Data 11 mai 2021 20:56:07
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.83 kb
#include <bits/stdc++.h>

using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
const int MOD = 100003;
int n,o,x,h;
vector<int> v[MOD];
int main()
{
    f>>n;
    for(;n;n--)
    {
        f>>o>>x;
        h=x%MOD;
        vector<int>::iterator it;
        for(it = v[h].begin();it!=v[h].end();it++)
            if(*it==x)
                break;
        if(o==1)
        {
            if(it==v[h].end())
                v[h].push_back(x);
        }
        else
            if(o==2)
            {
                if(it!=v[h].end())
                {
                    *it=v[h].back();
                    v[h].pop_back();
                }
            }
        else
            if(it==v[h].end())
                g<<"0\n";
        else
            g<<"1\n";
    }
    return 0;
}