Cod sursa(job #2806685)

Utilizator TeodorMarciucMarciuc Teodor TeodorMarciuc Data 22 noiembrie 2021 21:46:27
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.18 kb
#include<iostream>
#include<fstream>
#include<vector>
using namespace std;
int i,j,k,l,m,p,x,n;
#define MOD 666013
vector<vector<int>>Hash;
int main()
{
    ifstream cin("hashuri.in");
    ofstream cout("hashuri.out");
    cin>>n;
    Hash.resize(MOD+2);
    for(i=1; i<=n; i++)
    {
        cin>>p>>x;
        int cat=x/MOD;
        int rest=x%MOD;
        bool ok=0;
        if(p==1)
        {
            for(auto j:Hash[rest])
                if(j==cat)
                {
                    ok=1;
                    break;
                }
            if(ok==0) Hash[rest].push_back(cat);
        }
        else if(p==2)
        {
            int cnt=0;
            for(auto j:Hash[rest])
            {
                if(j==cat)
                {
                    Hash[rest].erase(Hash[rest].begin()+cnt);
                }
                cnt++;
            }
        }
        else if(p==3)
        {
            for(auto j:Hash[rest])
                if(j==cat)
                {
                    ok=1;
                    break;
                }
            if(ok==1) cout<<1<<'\n';
            else cout<<0<<'\n';
        }
    }
}