[报告]
非常非常裸的最小环……
不过我实在是太惊讶了,因为URAL里的太多题目都是有多解的,弄的我郁闷万分。最后只好把别人的给交了。
程序并不是很出色,请不要盲目模仿——这个程序是不能AC的。
说句实话,我也不知道它为什么不能AC。
[程序]
// TASK: 1004 Sightseeing tripvar
ans,n,m,len:longint;
maint:longint;
tt,t,p:array [0..101,0..101] of longint;
a:array [0..101] of longint;
procedure init;
var
i,j,k,s:longint;
begin
fillchar(t,sizeof(t),7);
fillchar(maint,sizeof(maint),7);
readln(m);
for i:=1 to m do
begin
readln(j,k,s);
if s<t[j,k] then
begin
t[j,k]:=s;
t[k,j]:=s;
end;
end;
end;
procedure ouot;
var
i,j,k:longint;
begin
if len>0 then
begin
write(a[1]);
for i:=2 to len do
write(' ',a[i]);
writeln;
end else writeln('No solution.')
end;
procedure calc;
var
i,j,k:longint;
s:longint;
procedure found(i,j:longint);
begin
if p[i,j]>0 then
begin
found(i,p[i,j]);
inc(len);
a[len]:=p[i,j];
found(p[i,j],j);
end;
end;
begin
fillchar(p,sizeof(p),255);
tt:=t;
len:=0;
ans:=maint;
for i:=1 to n do
for j:=1 to n do
if t[i,j]<maint then
writeln(i:2,' -> ',j:2,' ',t[i,j]:3);
for k:=1 to n do
begin
for i:=1 to k-1 do
for j:=1 to k-1 do
if (i<>j)and(ans>tt[i,j]+t[i,k]+t[k,j]) then
begin
ans:=tt[i,j]+t[i,k]+t[k,j];
// write(ans,' : ');
len:=0;
found(i,j);
inc(len);
a[len]:=j;
inc(len);