Cod sursa(job #2461931)

Utilizator stefantagaTaga Stefan stefantaga Data 26 septembrie 2019 16:04:08
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.02 kb
#include <bits/stdc++.h>
#define MOD 666013
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
vector <int> v[MOD];
int gaseste(int x)
{
    int rest=x%MOD;
    for (int i=0;i<v[rest].size();i++)
    {
        if (v[rest][i]==x)
        {
            return i;
        }
    }
    return -1;
}
void bag (int x)
{
    int rest=x%MOD;
    if (gaseste(x)==-1)
    {
        v[rest].push_back(x);
    }
}
void scot (int x)
{
    int rest=x%MOD;
    if (gaseste(x)!=-1)
    {
        v[rest][gaseste(x)]=0;
    }
}
int n,i,tip,x;
int main()
{
    f>>n;
    for (i=1;i<=n;i++)
    {
        f>>tip>>x;
        if (tip==1)
        {
            bag(x);
        }
        else
        if (tip==2)
        {
            scot(x);
        }
        else
        {
            if (gaseste(x)==-1)
            {
                g<<"0";
            }
            else
            {
                g<<"1";
            }
            g<<'\n';
        }
    }
    return 0;
}