Pagini recente » Cod sursa (job #1237696) | Cod sursa (job #2451275) | Cod sursa (job #2980321) | Cod sursa (job #1245305) | Cod sursa (job #280116)
Cod sursa(job #280116)
type lista=^element;
element=record
i:longint;
a:lista;
end;
var v:array[1..666013] of lista;
i,ct,n,a,b:longint;
p:lista;
function exista:boolean;
var w:lista;
begin
w:=v[b mod ct];
while w<>nil do
begin
if w^.i=b then exista:=true;
w:=w^.a;
end;
exista:=false;
end;
begin
assign(input,'hashuri.in'); reset(input);
assign(output,'hashuri.out'); rewrite(output);
ct:=666013;readln(n);
while (n>=1) do
begin
readln(a,b);
if a=1 then
begin
if not exista then
begin
new(p);
p^.i:=b;
p^.a:=v[b mod ct];
v[b mod ct]:=p;
end;
end
else
if a=2 then
begin
p:=v[b mod ct];
while p<>nil do
begin
if p^.i=b then p^.i:=0;
p:=p^.a;
end;
end
else
begin
if exista then writeln('1')
else writeln('0');
end;
dec(n);
end;
close(input);
close(output);
end.