Program Travel; var m:1..100;
{m为开通的单向巴士线路数} n:1..500;
{n为车站总数} result:array[1..501] of -1..100;{到某车站的最少换车数} num:array[1..500,1..50] of 1..500;{从某车站可达的所有车站序列}sum:array[1..500] of 0..50;
{从某车站可达的车站总数}check:array[1..500] of Boolean;{某车站是否已扩展完} procedure Init; var f1:text;a,b,c,d:byte;data:array[1..100] of 0..100; beginassign(f1,'input.txt');reset(f1);readln(f1,m);readln(f1,n);result[501]:=100;for a:=1 to m dobegin
for b:=1 to 100 do data:=0;
b:=0;
repeat
inc(b);
read(f1,data);
until eoln(f1);
for c:=1 to b-1 do
for d:=c+1 to b do
begin
inc(sum[data[c]]);
num[data[c],sum[data[c]]]:=data[d];
end; end; end; Procedure Done; var min,a,b,c,total:integer; beginfillchar(result,sizeof(result),-1);result[1]:=0;for c:=1 to sum[1] do result[num[1,c]]:=0;b:=data[1,1];repeat for c:=1 to sum do
if (result[num[b,c]]=-1) then result[num[b,c]]:=result+1;
min:=501;
for c:=1 to n do if (result[c]-1) and (result[c]-1; writeln(result[n]);{到达S公园的最少换车次} end; begin Init; end. 留着你的分吧,50分够了 |