Cod sursa(job #275542)

Utilizator rendorzegAndrei Pavel rendorzeg Data 10 martie 2009 15:38:06
Problema Floyd-Warshall/Roy-Floyd Scor 50
Compilator fpc Status done
Runda Arhiva educationala Marime 0.7 kb
const nmax=100;
      inf=maxint div 2;
type mat=array [1..nmax,1..nmax] of real;
     mult=set of byte;
var c:mat;
    d:array [1..nmax,1..nmax] of mult;
    i,j,n,k:integer;
    f,g:text;
begin
assign(f,'royfloyd.in');
reset(f);
assign(g,'royfloyd.out');
rewrite(g);
readln(f,n);
for i:=1 to n do
    for j:=1 to n do
            read(f,c[i,j]);
close(f);
for k:=1 to n do
    for i:=1 to n do
        for j:=1 to n do
          if i<>j then
             if (c[i,k]>0) and (c[k,j]>0) and (c[i,j]>c[i,k]+c[k,j]) then
                c[i,j]:=c[i,k]+c[k,j];

for i:=1 to n do  begin
    for j:=1 to n do
             write(g,trunc(c[i,j]),' ');
    writeln(g);
    end;
close(g);
end.