Cod sursa(job #2610980)

Utilizator stanbianca611Stan Bianca stanbianca611 Data 5 mai 2020 23:29:00
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.25 kb
#include <bits/stdc++.h>
using namespace std;
ifstream f ("hashuri.in");
ofstream g ("hashuri.out");
vector<int> h[666013];
int n, last;
int main()
{
    f>>n;
    for(int i=0; i<n; i++)
    {
        int x, y;
        f>>x>>y;
        int val=y%666013;
        if(x==1)
        {
           int exista=0;
            vector<int>::iterator it;
            for(it=h[val].begin(); it!=h[val].end(); it++)
                if(*it==x)
                {
                    exista=1;
                    break;
                }
           if(exista==0) h[val].push_back(y);
        }
        else if (x==2)
        {
            vector<int>::iterator it;
            for(it=h[val].begin(); it!=h[val].end(); it++)
                if(*it==y)
                {
                    h[val].erase(it);
                    break;
                }
        }
        else if(x==3)
        {
            int exista=0;
            vector<int>::iterator it;
            for(it=h[val].begin(); it!=h[val].end(); it++)
                if(*it==y)
                {
                    exista=1;
                    g<<1<<"\n";
                    break;
                }
            if(exista==0) g<<0<<"\n";
        }
    }
    return 0;
}