求高手指点

刚写的程序只过了两个数据,求高手指点。程序如下:

type r=array[1..1000] of record

mi:longint;

ma:longint;

end;

var team:array[1..1000] of boolean;

pa:array[1..1000,1..1000] of boolean;

a,v:array[1..1000] of longint;

city:r;

m,n,i,j,k,l,ma,t,h:longint;

procedure find;

var s:longint;

begin

l:=1; h:=0; t:=1;

team[1]:=true; a[1]:=1;

s:=0;

while ht do

begin

h:=h mod n+1;

for i:=1 to n do

if pa[a[h],i] then

begin

if (v[i]city[h].ma) then

begin

city[i].ma:=v[i];

if v[i]ma then ma:=s;

end

else

begin

city[i].mi:=city[h].mi;

city[i].ma:=city[h].ma;

end;

pa[a[h],i]:=false;

if team[i]=false then

begin

t:=t mod n +1;

a[t]:=i;

team[i]:=true;

end;

end;

team[h]:=false;

end;

end;

procedure map;

begin

read(n,m);

for i:=1 to n do

read(v[i]);

for i:=1 to m do

begin

read(j,k,l);

pa[j,k]:=true;

if l=2 then pa[k,j]:=true;

end;

end;

begin

fillchar(team,sizeof(team),false);

fillchar(pa,sizeof(pa),false);

map;

city[1].mi:=v[1]; city[1].ma:=v[1]; ma:=0;

city[n].ma:=0; city[n].mi:=0;

find;

if (city[n].ma>0) or (city[n].mi>0) then

write(ma)

else write(0);

end.

1 条评论

  • 1

信息

ID
1754
难度
6
分类
图结构 | 最短路 点击显示
标签
递交数
2908
已通过
747
通过率
26%
被复制
10
上传者