#P7642. [BalticOI 2006] JUMP THE BOARD! (Day 2)
[BalticOI 2006] JUMP THE BOARD! (Day 2)
Description
An game board is filled with integers, one non-negative integer in each cell. The goal is to jump from the top-left corner to the bottom-right corner along any valid path. The integer in any cell gives the jump length when leaving that cell. If a jump length would move you outside the board, then the jump in that specific direction is forbidden. All jumps must be either to the right or downward. Note that is a dead end and prevents any further progress.
As shown in Figure , on the board, the solid circle marks the start position and the dashed circle marks the target position. Figure shows three valid paths from the start to the target, and in each path the irrelevant numbers are removed.

Your task is to write a program to determine the number of valid paths from the top-left corner to the bottom-right corner.
Input Format
The first line contains a positive integer , the number of rows and columns of the board. The next lines follow. Each line contains integers, and each integer is in the range .
Output Format
The only line contains one integer, the number of valid paths from the top-left corner to the bottom-right corner.
4
2 3 3 1
1 2 1 3
1 2 3 1
3 1 1 0
3
Hint
Constraints
- For of the testdata, .
- The number of valid paths can be quite large. Using a -bit integer variable (in C,
long long int, in Pascal,Int64) can only get of the score. It is guaranteed that for all inputs, the number of paths can be written with no more than digits.
Notes
The problem comes from Baltic Olympiad in Informatics 2006 Day 2: Jump.
Translated and organized by @求学的企鹅.
Translated by ChatGPT 5
京公网安备 11011102002149号