Cod sursa(job #3203781)

Utilizator G3K0Airinei Gabriel Vlad G3K0 Data 14 februarie 2024 16:13:45
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.95 kb
#include <bits/stdc++.h>

using namespace std;
#define int long long
const int mod = 666013;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
vector < int > G[mod];
bool find_value (int x)
{
    int m=x%mod;

    for(auto it : G[m])
        if(it==x)
            return 1;
    return 0;
}

int32_t main()
{
    int n ;
    f>>n;
    int i,p;
    while(n--)
    {
        f>>i>>p;
        int m=p%mod;
        if(i==1)
            if(!find_value(p))
                G[m].push_back(p);
        if(i==2)
            if(find_value(p))
            {

                vector<int > :: iterator it;
                for(it=G[m].begin(); it!=G[m].end(); ++it)
                    if(p==(*it))
                    {
                        G[m].erase(it);
                        break;

                    }
            }
        if(i==3)
        {
            g<<find_value(p)<<'\n';

        }


    }



    return 0;
}