Cod sursa(job #773663)

Utilizator BlueStrutAndrei Prahoveanu BlueStrut Data 2 august 2012 12:30:20
Problema Hashuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.81 kb
#include<cstdio>
#include<algorithm>
using namespace std;
int i, x, op, it;
const Mod=1003
vector <int> h[Mod]
vector <int>::iterator it;
int find_v()
    int i;
    for (it=h[ind].begin();it!=h[ind].end();++it) if (*it==x) return it;
    return it;
}
void insert_v(int x) {
    if (it==h[ind].end()) h[ind].push_back(x);
}
void erase_v(int x) {
    if (it!=h[ind].end()) h[ind].erase(it);
}
void print_v(int x) {
    if (it==h[ind].end()) printf("0\n"); else printf("1\n");
}
int main(){
    freopen("hashuri.in","r",stdin);
    freopen("hashuri.out","w",stdout);
    scanf("%d", &n);
    for (i=1;i<=n;i++) {
        scanf("%d%d", &op, &x);
        ind=x/Mod;
        find_v(x);
        if (op==1) insert_v(x);
        if (op==2) erase_v(x);
        if (op==3) print_v(x);
    }
    return 0;
}