Mock CCO '17 Problem 5 - Blitzkrieg
View as PDF has successfully killed Fuehrer King Bradley, but he must now escape. His time machine requires a lightning storm to gain enough energy. There are cities in Amestris and
roads. is located in city
and the time machine is in city
. There are
days before the lightning storm, on which must be located in city
. In addition, would like to make sure that there are at least
distinct paths to city
, to make it harder for the Amestris army to track him. Unfortunately, each road has an alertness level. Note that must change take a road each day, or the Amestris army will catch up to him.
would like to know the minimum alertness level he is required to pass in order to have distinct paths of length
from
to
, or
if it is impossible.
Subtasks
For all cases, ,
,
.
For points,
.
For additional points,
.
For additional points,
.
Input Specification
Line 1: ,
,
,
,
and
.
Next lines: 3 integers,
,
and
, representing a bidirectional path from
to
with alertness
.
Note: There may be multiple paths between two nodes.
Sample Input
3 5 6 3 0 2
0 1 5
0 0 4
1 2 1
1 2 6
0 2 12
Sample Output
5
Comments