Cod sursa(job #2555150)

Utilizator Codrut112Codrut Copas Codrut112 Data 23 februarie 2020 19:02:44
Problema Hashuri Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.87 kb
#include <bits/stdc++.h>

using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int n,i,op,rest,j,x,ok;
vector<int>v[666014];
int main()
{
    f>>n;
    for(i=1; i<=n; i++)
    {
        f>>op>>x;

        rest=x%666013;
        if(op==1) v[rest].push_back(x);
        if(op==2)
        {
            for(j=0; j<v[rest].size(); j++)
                if(v[rest][j]==x)
                {
                    swap(v[rest][j],v[rest][v[rest].size()-1]);
                    v[rest].pop_back();
                    break;
                }
        }
        if(op==3)
        {

            ok=0;
            for(j=0; j<v[rest].size(); j++)
                if(v[rest][j]==x)
                {
                    g<<1<<'\n';
                    ok=1;
                }
            if(ok==0)g<<0<<'\n';


        }



    }

}