Pagini recente » Cod sursa (job #3177500) | Cod sursa (job #1518435) | Cod sursa (job #1127626) | Cod sursa (job #1374689) | Cod sursa (job #1168258)
program hashuri;
const p=666013;
type lista=^celula;
celula=record
info:longint;
pred:lista;
end;
var a:array[0..p] of lista;
n,i,op,x:longint;
r:lista;
gasit:boolean;
buf1,buf2:array[1..1 shl 16] of char;
begin
assign(input,'hashuri.in');
assign(output,'hashuri.out');
reset(input);
rewrite(output);
settextbuf(input,buf1);
settextbuf(output,buf2);
readln(n);
while (n>0) do
begin
readln(op,x);
if op=1 then
begin
new(r);
r^.info:=x;
r^.pred:=a[x mod p];
a[x mod p]:=r;
end;
if op=2 then
begin
r:=a[x mod p];
if r<>nil then
while (r^.info=x) and (r^.pred<>nil) do r:=r^.pred;
if r<>nil then
if (r^.pred=nil) then
if (r^.info=x) then r:=nil;
a[x mod p]:=r;
if r<>nil then
if r^.pred<>nil then
while r^.pred<>nil do
begin
if r^.pred^.info=x then
r^.pred:=r^.pred^.pred;
r:=r^.pred;
end;
end;
if op=3 then
begin
r:=a[x mod p];
gasit:=false;
while (r<>nil) and(not gasit)do
begin
if r^.info=x then
gasit:=true;
r:=r^.pred;
end;
if gasit then writeln(1)
else writeln(0);
end;
dec(n);
end;
close(output);
end.