CF383B Volcanoes
Description
Iahub got lost in a very big desert. The desert can be represented as a $ n×n $ square matrix, where each cell is a zone of the desert. The cell $ (i,j) $ represents the cell at row $ i $ and column $ j $ $ (1
Input Format
The first line contains two integers $ n $ $ (1
Output Format
Print one integer, the minimum time in which Iahub can arrive at cell $ (n,n) $ . If no solution exists (there is no path to the final cell), print -1.
Explanation/Hint
Consider the first sample. A possible road is: $ (1,1) $ $ → $ $ (1,2) $ $ → $ $ (2,2) $ $ → $ $ (2,3) $ $ → $ $ (3,3) $ $ → $ $ (3,4) $ $ → $ $ (4,4) $ .