Cod sursa(job #1180253)
Utilizator | Data | 30 aprilie 2014 12:01:53 | |
---|---|---|---|
Problema | Hashuri | Scor | 20 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 1.93 kb |
Program hashuri;
const prim=900001;
var t,n,i,a,b,ok: longint;
lhash : array [0..5000,0..900001] of longint;
j,k,m : longint;
bin,bout : array [0..1 shl 17 ] of char;
nr: array[0..900001] of longint;
begin
assign(input,'hashuri.in');settextbuf(input,bin); reset(input);
assign(output,'hashuri.out'); settextbuf(output,bout); rewrite(output);
readln(t);
for m:=1 to t do begin
read(a,b);
case a of
1 : begin
ok:=0;
j:=b mod prim;
for i:=1 to nr[j] do
if lhash[i,j]=b then begin
ok:=1;
break;
end;
if ok=0 then begin
nr[j]:=nr[j]+1;
lhash[nr[j],j]:=b;
end;
end;
3 : begin
ok:=0;
j:=b mod prim;
for i:=1 to nr[j] do
if lhash[i,j]=b then begin
ok:=1;
break;
end;
writeln(ok);
end;
2 : begin
j:=b mod prim;
for i:=1 to nr[j] do
if lhash[i,j]=b then begin
for k:=i to nr[j]-1 do lhash[k,j]:=lhash[k+1,j];
lhash[nr[j],j]:=0;
break;
end;
end;
end;
end;
close(input);
close(output);
end.