5 adj
:array [0..maxn
,0..maxn
] of longint;
6 st
:array [0..maxn
] of string;
7 dis
:array [0..maxn
] of longint;
8 vis
:array [0..maxn
] of boolean;
15 fillchar(adj
,sizeof(adj
),0);
22 if st
[i
][k
]<>st
[j
][k
] then inc(adj
[i
,j
]);
26 fillchar(dis
,sizeof(dis
),$3F);
27 fillchar(vis
,sizeof(vis
),false);
34 if (not vis
[j
]) and ((k
=0) or (dis
[j
]<dis
[k
])) then k
:=j
;
39 if adj
[k
,j
]<dis
[j
] then dis
[j
]:=adj
[k
,j
];
41 writeln('The highest possible quality is 1/',ans
,'.');