Cod sursa(job #1224703)

Utilizator mihaimusatMihai Musat mihaimusat Data 31 august 2014 17:22:53
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.81 kb
#include <fstream>
#include <vector>

using namespace std;

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

const int mod = 666013;
vector <int> h[mod];

int main()
{
    int p,x,n,key,j;
    bool ok;
    f>>n;
    for(int i=0;i<n;++i) {
        ok = 0;
        f>>p>>x;
        key = x%mod;
        for(j=0;j<(int)h[key].size();++j) {
            if (h[key][j]==x) {
                ok = 1;
                break;
            }
        }
        if (p==1) {
            if (ok==0) {
                h[key].push_back(x);
            }
        } else if (p==2) {
            if (ok==1) {
                h[key][j] = h[key][h[key].size()-1];
                h[key].resize(h[key].size()-1);
            }
        } else if (p==3) {
            g<<ok<<'\n';
        }
    }
    return 0;
}