Pagini recente » Cod sursa (job #702421) | Cod sursa (job #2023116) | Cod sursa (job #2180285) | Cod sursa (job #704471) | Cod sursa (job #1179846)
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;
w,z:text;
begin
assign(w,'hashuri.in');
assign(z,'hashuri.out');
reset(input);
rewrite(output);
readln(n);
for i:=1 to n do begin
readln(w,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(z,1)else
writeln(z,0);
end;
end;
close(w);
close(z);
end.