Cod sursa(job #1180248)
Utilizator | Data | 30 aprilie 2014 11:49:33 | |
---|---|---|---|
Problema | Hashuri | Scor | 20 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 1.81 kb |
Program hashuri;
const prim=900001;
var t,n,i,a,b,ok: longint;
lhash : array [0..900001,0..3000] of longint;
j,k,m : longint;
bin,bout : array [0..1 shl 17 ] of char;
nr: array[0..3000] 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
for k:=i to nr[j] do lhash[k,j]:=lhash[k+1,j];
end;
end;
end;
close(input);
close(output);
end.