Cod sursa(job #2130924)

Utilizator CezarTDTodirisca Cezar CezarTD Data 14 februarie 2018 08:30:01
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.56 kb
#include <bits/stdc++.h>

using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
const int N = 100003;
vector<int> v[N];
int x,cod,h,n;

int main()
{
    f>>n;
    auto it=v[0].begin();
    for(;n;n--)
    {
        f>>cod>>x;
        h=x%N;
        for(it=v[h].begin();it!=v[h].end();it++)
            if(*it==x)
                break;
        if(cod==1&&it==v[h].end())v[h].push_back(x);
        if(cod==2&&it!=v[h].end()){*it=v[h].back();v[h].pop_back();}
        if(cod==3)g<<(it!=v[h].end())<<'\n';
    }
    return 0;
}