Cod sursa(job #395168)

Utilizator mimarcelMoldovan Marcel mimarcel Data 12 februarie 2010 12:36:02
Problema Hashuri Scor 0
Compilator fpc Status done
Runda Arhiva educationala Marime 0.73 kb
const maxnr=2000000000;
type  hash=array[0..maxnr]of boolean;
var n,i,x:longint;
    op:byte;
    h:hash;

procedure inithash(var h:hash);
begin
fillchar(h,sizeof(h),false);
end;

procedure adaug(var h:hash;var x:longint);
begin
h[x]:=true;
end;

procedure sterge(var h:hash;var x:longint);
begin
h[x]:=false;
end;

procedure cautare(var h:hash;var x:longint);
begin
if h[x] then writeln('1')
        else writeln('0');
end;

begin
assign(input,'hashuri.in');
assign(output,'hashuri.out');
rewrite(output);
reset(input);
readln(n);
inithash(h);
for i:=1 to n do
  begin
  readln(op,x);
  case op of
    1:adaug(h,x);
    2:sterge(h,x);
    3:cautare(h,x);
    end;
  end;
close(output);
close(input);
end.