Cod sursa(job #2283452)

Utilizator mihnea.anghelMihnea Anghel mihnea.anghel Data 15 noiembrie 2018 15:35:44
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.79 kb
#include <fstream>
#include <vector>
#include <algorithm>

#define mod 666013

using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int i,j,n,ok,pas,operatie,x;
vector <int> v[mod];
vector <int> :: iterator it;

int main()
{
    f>>n;
    for(pas=1;pas<=n;pas++)
    {
        f>>operatie>>x;
        it=find(v[x%mod].begin(), v[x%mod].end(), x);
        if( operatie==1 )
        {
            if( it==v[x%mod].end() )
                v[x%mod].push_back(x);
            continue;
        }
        if( operatie==2 )
        {
            if ( it!=v[x%mod].end() )
            v[x%mod].erase(it);
            continue;
        }
        if( it==v[x%mod].end() )
            g<<0<<"\n";
        else
            g<<1<<"\n";
    }
    return 0;
}