Cod sursa(job #2252947)

Utilizator DandeacDan Deac Dandeac Data 3 octombrie 2018 12:59:31
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 1.1 kb
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>

#define mod 666013
using namespace std;
ifstream f ("hashuri.in");
ofstream g ("hashuri.out");

vector<int>v[mod];
int n,op,x;
int main()
{
    f>>n;

    for(int i=1;i<=n;i++)
    {
        f>>op>>x;
        vector<int>::iterator it = find(v[x%mod].begin(), v[x%mod].end(), x);
        switch(op)
        {
            case 1:
                {
                     if(it == v[x%mod].end())
                    v[x%mod].push_back(x);
                }
                break;
            case 2:
                {
                     if(it!=v[x%mod].end())
                    {
                        *it = v[x%mod][v[x%mod].size()-1];
                        v[x%mod].pop_back();
                    }
                }
                break;
            case 3:
                {
                    if(it != v[x%mod].end())
                        g<<1<<"\n";
                   else
                        g<<0<<"\n";
                }
                break;
        }
    }
    return 0;
}