Pagini recente » Cod sursa (job #956798) | Cod sursa (job #1760563) | Cod sursa (job #2455752) | Cod sursa (job #1365831) | Cod sursa (job #1179842)
program hashuri;
const p= 46381;
type lista=^celula;
celula=record
info:int64;
pred:lista;
end;
var a:array[0..p] of lista;
n,op,x,i:longint;
r,q:lista;
u:boolean;
begin
assign(input,'hashuri.in');
assign(output,'hashuri.out');
reset(input);
rewrite(output);
readln(n);
for i:=1 to n do begin
readln(op,x);
if op=1 then
begin
u:=false;
r:=a[x mod p];
while r<>nil do begin
if r^.info=x then u:=true;
r:=r^.pred;
end;
if not u then
begin
new(r);
r^.info:=x;
r^.pred:=a[x mod p];
a[x mod p]:=r;
end;
end;
if op=2 then
begin
r:=a[x mod p];
if( r<>nil) then
begin
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 q:=r;
r:=r^.pred;
end;
if q<>nil then
q^.pred:=q^.pred^.pred;
end;
end;
end;
if op=3 then
begin
u:=false;
r:=a[x mod p];
while r<>nil do begin
if r^.info=x then
u:=true;
r:=r^.pred;
end;
if u then
writeln(1)else
writeln(0);
end;
end;
close(output);
end.