Cod sursa(job #2252935)

Utilizator DandeacDan Deac Dandeac Data 3 octombrie 2018 12:41:04
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.94 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].end();
                    v[x%mod].pop_back();
                }
                break;
            case 3:
                if(it != v[x%mod].end())
                    g<<1<<"\n";
                else
                    g<<0<<"\n";
                break;
        }
    }
    return 0;
}