Canadian Computing Competition: 2005 Stage 2, Day 1, Problem 1
Johnny Canuck has been trapped in the matrix: no, not that matrix. This matrix is a grid of width
Johnny can pick any position on the first row to begin at. He must make it to row
However, there is a restriction. Johnny can only choose a trinity of numbers (from the range
The path may begin at any position in row
Input Specification
The first line of input contains the two integers
Output Specification
The output is one line long, containing three integers: the trinity of numbers that Johnny should choose in order to escape the matrix. If there is no path from row -1
. If there is a path, then the lexicographically first three numbers should be outputted. (Notice that
Sample Input
6 5
0 1 2 3 4 5
0 0 0 1 1 1
0 1 2 3 3 4
5 1 4 1 9 4
9 5 6 2 4 6
Sample Output
0 1 5
Comments