cowhome.pas
来自「Magio牛的usaco源代码」· PAS 代码 · 共 31 行
PAS
31 行
{
PROB:cowhome
LANG:PASCAL
}
program cowhome;
const
maxn=1000;
maxt=2000;
var
dist:array[1..maxn]of longint;
v1,v2:array[1..maxt]of word;
l:array[1..maxt]of byte;
t,n,i,j:word;
begin
assign(input,'cowhome.in');reset(input);
assign(output,'cowhome.out');rewrite(output);
read(t,n);
for i:=1 to t do
read(v1[i],v2[i],l[i]);
for i:=2 to n do
dist[i]:=999999;
for i:=2 to n do
for j:=1 to t do begin
if dist[v1[j]]+l[j]<dist[v2[j]] then dist[v2[j]]:=dist[v1[j]]+l[j];
if dist[v2[j]]+l[j]<dist[v1[j]] then dist[v1[j]]:=dist[v2[j]]+l[j];
end;
writeln(dist[n]);
close(input);close(output);
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?