#P379. 练65.2 跳房子
练65.2 跳房子
Description
The cows are playing a non-traditional version of the children's "hopscotch" game. Instead of a linear arrangement of numbered squares, they have created a grid of numbers, aligned with the and axes. The cows skillfully jump from number to number in the grid: forward, backward, left, or right (never diagonally), landing on another number in the grid. They continue jumping (using the same rules), possibly landing on numbers they've already visited. After a total of five jumps, their path forms a six-digit integer (which may start with , e.g., ). Find the total number of distinct integers that can be formed in this way.
Input Format
Lines to : The grid, each line contains integers.
Output Format
Line : The total number of distinct integers that can be formed.
Sample
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 2 1
1 1 1 1 115
Related
In following homework: