var adj : array 0 .. 12, 0 .. 12 of int
for i : 0 .. 12
for j : 0 .. 12
adj (i, j) := 100000
end for
end for
var fi, fo : int
open : fi, "DATA51.txt", get
open : fo, "OUT51.txt", put
var N, d : int
var line : string
get : fi, N
for i : 1 .. N
get : fi, line
get : fi, d
adj (ord (line (1)) - 65, ord (line (2)) - 65) := d
adj (ord (line (2)) - 65, ord (line (1)) - 65) := d
end for
for k : 0 .. 12
for i : 0 .. 12
for j : 0 .. 12
adj (i, j) := min (adj (i, j), adj (i, k) + adj (k, j))
end for
end for
end for
for : 1 .. 5
get : fi, line
put : fo, adj (ord (line (1)) - 65, ord (line (2)) - 65)
end for
close (fi)
close (fo) |