记录编号 |
3409 |
评测结果 |
AAAAAAAAAA |
题目名称 |
Perform巡回演出 |
最终得分 |
100 |
用户昵称 |
elysian |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.027 s |
提交时间 |
2008-10-06 21:35:50 |
内存使用 |
0.53 MiB |
显示代码纯文本
program perform;
const
fin='candy.in';fout='candy.out';
maxl=20000000;
var
c:array[1..10,1..10,1..1000] of longint;
f:array[1..1000,1..10] of longint;
n,k:longint;
f1,f2:text;
procedure main;
var
i,j,p:longint;
BEGIN
for i:=1 to k do
for j:=1 to n do f[i,j]:=maxl;
for i:=2 to n do f[1,i]:=c[1,i,1];
for i:=2 to k do
for j:=1 to n do
for p:=1 to n do
if (f[i-1,p]+c[p,j,i])<f[i,j] then f[i,j]:=f[i-1,p]+c[p,j,i];
if f[k,n]<>maxl then writeln(f2,f[k,n])
else writeln(f2,0);
END;
procedure initc;
var
i,j,p:longint;
begin
for i:=1 to n do
for j:=1 to n do
for p:=1 to k do c[i,j,p]:=maxl;
end;
procedure init;
var
i,j,p,d:longint;
BEGIN
assign(f1,fin);reset(f1);
assign(f2,fout);rewrite(f2);
repeat
readln(f1,n,k);
initc;
if n<>0 then
begin
for i:=1 to n do
for j:=1 to n do
if j<>i then
begin
read(f1,d);
for p:=1 to d do begin read(f1,c[i,j,p]);if c[i,j,p]=0 then c[i,j,p]:=maxl;end;
if d<k then
for p:=d+1 to k do c[i,j,p]:=c[i,j,p-d];
end;
main;
end;
until (n=0)and(k=0);
close(f1);
END;
begin
init;
close(f2);
end.