ac1102.pas
来自「某牛人写的acm.tongji.edu.cn上大部分ac的代码,仅供学习研究,请」· PAS 代码 · 共 32 行
PAS
32 行
program tju1102;
const
maxn=20000;
var
a:array[1..maxn]of word;
n,i,t,u,op,len,maxlen:word;
begin
repeat
read(n);
for i:=1 to n do
read(a[i]);
op:=n;maxlen:=0;
for i:=1 to n do
if a[i]>0 then begin
dec(op);
t:=i;len:=0;
repeat
u:=a[t];a[t]:=0;inc(len);t:=u;
until a[t]=0;
if len>maxlen then maxlen:=len;
end;
write(op,' ');
case maxlen of
1:writeln(0);
2:writeln(1);
else writeln(2);
end;
until seekeof;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?