Cod sursa(job #150943)

Utilizator petrePajarcu Alexandru-Petrisor petre Data 7 martie 2008 17:36:38
Problema Floyd-Warshall/Roy-Floyd Scor 100
Compilator fpc Status done
Runda Arhiva educationala Marime 0.55 kb
var a:array[1..100,1..100] of longint;
n,i,j,k,l:longint;
begin
assign(input,'royfloyd.in');
assign(output,'royfloyd.out');
reset(input);
rewrite(output);
readln(N);
for i:=1 to n do
for j:=1 to n do
    read(a[i,j]);
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
if (I<>J) then
if (a[i,k]<>0)and(a[k,j]<>0) then
if (a[i][j]=0) or (a[i][j]>a[i][k]+a[k][j]) then
       begin
       a[i][j]:=a[i][k]+a[k][j];
       end;
for i:=1 to n do
begin
for j:=1 to n do
write(a[i,j],' ');
writeln;
end;
close(input);
close(output);
end.