Cod sursa(job #2396014)

Utilizator MstrGreenChim Vladimir MstrGreen Data 3 aprilie 2019 09:47:58
Problema Floyd-Warshall/Roy-Floyd Scor 100
Compilator fpc Status done
Runda Arhiva educationala Marime 0.52 kb
type tabel=array[1..100,1..100] of longint;
var n,i,j,k,a,b:longint;
    t:tabel;
begin
assign(input,'royfloyd.in');
assign(output,'royfloyd.out');
reset(input);
rewrite(output);
read(n);
for i:=1 to n do
for j:=1 to n do read(t[i,j]);
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
if (t[i,k]<>0) and (t[k,j]<>0) then
if ((t[i,j]>t[i,k]+t[k,j]) or (t[i,j]=0)) and (i<>j) then
t[i,j]:=t[i,k]+t[k,j];
for i:=1 to n do begin
for j:=1 to n do write(t[i,j],' ');
writeln end;
close(input);
close(output);
end.