Cod sursa(job #2708081)

Utilizator Botnaru_VictorBotnaru Victor Botnaru_Victor Data 18 februarie 2021 11:44:37
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.93 kb
#include <bits/stdc++.h>

#define P 66603

using namespace std;

vector<vector<int> > m(P);

vector<int>::iterator exists(int v)
{
    int poz=v%P;
    for(vector<int>::iterator res=m[poz].begin();res<m[poz].end();res++)
        if (*res==v) return res;
    return m[poz].end();
}

int main()
{
    freopen("hashuri.in","r",stdin);
    freopen("hashuri.out","w",stdout);

    int n,a,b;
    scanf("%i",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%i %i",&a,&b);
        vector<int>::iterator j=exists(b);
        switch(a)
        {
        case 1:
            if(j==m[b%P].end())
               m[b%P].push_back(b);
            break;
        case 2:
            if(j!=m[b%P].end())
                m[b%P].erase(j);
            break;
        case 3:
            if(j!=m[b%P].end())
                printf("1 \n");
            else
                printf("0 \n");

        }
    }

    return 0;
}