Cod sursa(job #1527001)

Utilizator vladutz15FMI Cornoiu Vlad vladutz15 Data 17 noiembrie 2015 19:22:09
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 1.37 kb
#include <iostream>
#include <fstream>
#include <vector>

#define MOD 666013

using namespace std;

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

int n, tip, x, val,t;

vector <int> v[MOD+5];

int main()
{
    f>>n;
    for (;n;--n)
    {
        f>>tip>>x;
        if (tip == 1)
        {
            val = x % MOD;
            v[val].push_back(x);
        }
        else if (tip==2)
        {
            val = x % MOD;
            for (vector<int>::iterator it = v[val].begin(); it!=v[val].end();++it)
            {
                if ((*it)==x)
                {
                    (*it)=v[val].back();
                    v[val].pop_back();
                    break;
                }
            }
        }
        else
        {
            t=0;
            val = x % MOD;
            for (vector<int>::iterator it = v[val].begin(); it!=v[val].end();++it)
                if ((*it) == x)
                {
                    t=1;
                    break;
                }
            g<<t<<"\n";
        }
    }
    return 0;
}

/*
(1) infoarena.ro/problema/hashuri
(2) infoarena.ro/problema/loto
(3) infoarena.ro/problema/strmatch
(4) infoarena.ro/problema/per

suplimentar:

http://codeforces.com/contest/19/problem/C
(Problema B)- https://github.com/palcu/rotopcoder/raw/master/coliziune/enunturi.pdf


*/