Cod sursa(job #1054705)

Utilizator CostanMiriamCostan Miriam CostanMiriam Data 14 decembrie 2013 10:01:18
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.79 kb
#include <fstream>
#include <list>
# define DIM 935674
using namespace std;
ifstream fin ("hashuri.in");
ofstream fout ("hashuri.out");

list <int> l[DIM];
list <int>::iterator it ;

int o,x,y,i,n,ok;

int main () {

    fin>>n;

    for (i=1;i<=n;i++) {
        fin >>o>>x;
        if (o==1) {
            y=x%DIM;
            l[y].remove (x);
            l[y].push_back(x);
        }
        if (o==2) {
            y=x%DIM;
            l[y].remove (x);
        }
        if (o==3) {
            y=x%DIM;
            ok=0;
            for (it=l[y].begin(); it !=l[y].end() ; it++){
                if (*it == x) {
                    ok=1;
                    break;
                }
            }
            fout<<ok<<"\n";
        }
    }


    return 0;
}