H
hai6f2009
Chắc suất Đại học top - Giữ chỗ ngay!! ĐĂNG BÀI NGAY để cùng trao đổi với các thành viên siêu nhiệt tình & dễ thương trên diễn đàn.
mình mong các bạn sửa cho mình bài sau (lỗi exitcode=216):
program dulich;
const fi='dulich.inp';
fo='dulich.out';
var f:text;
c,l,u:array[1..100000,1..100000] of longint;
x:array [1..100000] of integer;
r,cs,s,i,j,n,k:integer;
min:longint;
procedure enter;
begin
assign(f,fi);reset(f);
readln(f,n);
for i:=1 to n do
begin
for j:=1 to n do read(f,c[i,j]);
readln(f);
end;
close(f);
end;
procedure optimize;
begin
for s:=1 to n do
begin
l[s,s]:=0;
u[s,s]:=-1;
end;
r:=1;
for s:=2 to n do
begin
min:=1000000;cs:=-1;
for k:=r to s-1 do
if c[k,s]>0 then
if l[r,k]+c[k,s]<min then
begin
min:=l[r,k]+c[k,s];
cs:=k;
end;
l[r,s]:=l[r,cs]+c[cs,s];
u[r,s]:=cs;
end;
end;
procedure trace;
begin
i:=1;s:=n;r:=1;x[1]:=s;
while s<>r do
begin
i:=i+1;
s:=u[r,s];
x:=s;
end;
end;
procedure printresult;
begin
assign(f,fo);rewrite(f);
for i:=i downto 1 do write(x[j],'-->');
close(f);
end;
BEGIN
enter;
optimize;
trace;
printresult;
END.
program dulich;
const fi='dulich.inp';
fo='dulich.out';
var f:text;
c,l,u:array[1..100000,1..100000] of longint;
x:array [1..100000] of integer;
r,cs,s,i,j,n,k:integer;
min:longint;
procedure enter;
begin
assign(f,fi);reset(f);
readln(f,n);
for i:=1 to n do
begin
for j:=1 to n do read(f,c[i,j]);
readln(f);
end;
close(f);
end;
procedure optimize;
begin
for s:=1 to n do
begin
l[s,s]:=0;
u[s,s]:=-1;
end;
r:=1;
for s:=2 to n do
begin
min:=1000000;cs:=-1;
for k:=r to s-1 do
if c[k,s]>0 then
if l[r,k]+c[k,s]<min then
begin
min:=l[r,k]+c[k,s];
cs:=k;
end;
l[r,s]:=l[r,cs]+c[cs,s];
u[r,s]:=cs;
end;
end;
procedure trace;
begin
i:=1;s:=n;r:=1;x[1]:=s;
while s<>r do
begin
i:=i+1;
s:=u[r,s];
x:=s;
end;
end;
procedure printresult;
begin
assign(f,fo);rewrite(f);
for i:=i downto 1 do write(x[j],'-->');
close(f);
end;
BEGIN
enter;
optimize;
trace;
printresult;
END.