Cod sursa(job #1941445)

Utilizator nartorrewrew narto Data 27 martie 2017 12:13:30
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.84 kb
#include <fstream>
#include <vector>
#define mod 66013
#define nmax 1000004
using namespace std;

ifstream f("hashuri.in");
ofstream g("hashuri.out");

int n, op, i, x, ok;
vector<int>v[nmax];
vector<int>::iterator it;
int main()
{
    f>>n;
   while(n!=0){
     f>>op>>x;
     i=x%mod;
        if(op==1) v[i].push_back(x);
        else if(op==2){
            for(it=v[i].begin();it!=v[i].end();it++)
                if(*it==x){
                v[i].erase(it);
                break;
           }
        }
        else if(op==3){
             ok=0;
             for(it=v[i].begin();it!=v[i].end();it++)
                if(*it==x){
                    g<<1<<'\n';
                    ok=1;
                    break;
                }
            if(ok==0)
                g<<0<<'\n';
        }
        n--;
   }

}