Cod sursa(job #2911332)

Utilizator mitoceanuci@gmail.comMitoceanu Ciprian [email protected] Data 28 iunie 2022 16:14:01
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.83 kb
#include <bits/stdc++.h>

using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");

int n,o,x;
const int H=100003;
vector<int> v[H];


int main()
{
    fin>>n;
    for(; n; n--)
    {
        fin>>o>>x;
        int h=x%H;
        int k=v[h].size(),i;
        for(i=0; i<k; i++)
        {
            if(v[h][i]==x)
            {
                break;
            }
        }
        if(o==1)
        {
            if(i==k)
            {
                v[h].push_back(x);
            }
        }
        else if(o==2)
        {
            if(i<k)
            {
                swap(v[h][i],v[h][k-1]);
                v[h].pop_back();
            }
        }
        else if(i==k){
            fout<<"0\n";
        }
        else
            fout<<"1\n";
    }
    return 0;
}