#P4825. Cow Hopscotch
Cow Hopscotch
Cow Hopscotch
Cows have invented their own version of hopscotch on a grid. The game is played on an \(R \times C\) grid where each cell contains an integer between \(1\) and \(K\). The cows start at the top-left cell and must reach the bottom-right cell by a sequence of jumps. A jump from cell \((r, c)\) to cell \((r', c')\) is valid if and only if:
- The destination cell has a different integer than the current cell.
- \(r' > r\) (i.e., the jump goes at least one row down).
- \(c' > c\) (i.e., the jump goes at least one column to the right).
Your task is to compute the number of different jump sequences that take the cows from the top-left cell to the bottom-right cell.
Note: The grid dimensions satisfy \(2 \le R \le 100\) and \(2 \le C \le 100\) and \(1 \le K \le R \times C\).
inputFormat
The first line contains three integers: \(R\), \(C\) and \(K\). Each of the next \(R\) lines contains \(C\) integers representing the grid.
For example:
2 2 4 1 2 3 4
outputFormat
Output a single integer: the number of distinct valid jump sequences from the top-left cell to the bottom-right cell.
sample
2 2 4
1 2
3 4
1