Pagini recente » Cod sursa (job #461008) | Cod sursa (job #499746) | Cod sursa (job #821676) | Cod sursa (job #1010676) | Cod sursa (job #1168082)
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
if r^.info=x then
a[x mod p]:=a[x mod p]^.pred
else
begin
while (r^.pred<>nil)
do begin
if r^.pred^.info=x
then r^.pred:=r^.pred^.pred;
r:=r^.pred;
end;
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.