Cod sursa(job #908335)

Utilizator DaNutZ2UuUUBB Bora Dan DaNutZ2UuU Data 9 martie 2013 10:54:27
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.83 kb
#include <fstream>
#include <vector>
#define MOD 666013
using namespace std;
ifstream fin("hashuri.in"); ofstream fout("hashuri.out");

int n,tip,val,poz,m,c;
vector <int> x[MOD + 1];

int main()
{
    fin >> n;
    for(int i = 1; i <= n; i++)
    {
        fin >> tip >> val;
        m = val % MOD;
        c = val / MOD;
        for(poz = 0; poz < x[m].size() && x[m][poz] != c ;poz++);
            if(tip == 1)
                x[m].insert(x[m].begin() + poz, c);
            else if(tip == 2)
            {
                if(poz < x[m].size())
                    x[m].erase(x[m].begin() + poz);
            }
            else
                if(poz >= x[m].size())
                    fout << "0\n";
                else
                    fout << "1\n";
    }
    fin.close(); fout.close();
    return 0;
}