Cod sursa(job #2591451)

Utilizator gruhtenZinnenberg Gruhten gruhten Data 30 martie 2020 16:05:17
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.74 kb
#include <bits/stdc++.h>
using namespace std;

ifstream f("hashuri.in");
ofstream g("hashuri.out");

const int  Mod=666013;

vector <int>V[Mod];

int main()
{
    int x,N,c,b,poz,Ok;
    f>>N;
    while(N--)
    {
        f>>c>>x;
        b=x%Mod;
        Ok=0;

        for(unsigned int j=0;j<V[b].size();j++)
        {
            if(V[b][j]==x)
            {
                Ok=1;
                poz=j;
                j=V[b].size();
            }
        }

        vector<int>::iterator it=V[b].begin();
        it=it+poz;

        if(c==1 and Ok==0)
            V[b].push_back(x);
        else if(c==2 and Ok==1)
            V[b].erase(it);
        else if(c==3)
            g<<Ok<<"\n";

    }
    return 0;
}