Cod sursa(job #2283264)

Utilizator mihnea.anghelMihnea Anghel mihnea.anghel Data 15 noiembrie 2018 11:56:03
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.71 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 && it==v[x%mod].end() )
            v[x%mod].push_back(x);
        if( operatie==2 && it!=v[x%mod].end() )
            v[x%mod].erase(it);
        if(operatie==3 && it==v[x%mod].end())
            g<<0<<endl;
        if(operatie==3 && it!=v[x%mod].end())
            g<<1<<endl;
    }
    return 0;
}