Submit | All submissions | Best solutions | Back to list |
TRAVERSE - Traverse through the board |
An n × n game board is filled with integers, one positive integer per square. The objective is to travel along any legitimate path from the upper left corner to the lower right corner of the board.
Rules:
- The number in any one square describes how far a step away from that location must be.
- If the step size moves out of the game board, then that step is not allowed.
- All steps must be either to the right or towards the bottom.
Note that a 0 is a dead end which prevents any further progress.
Consider the 4 × 4 board shown in Figure 1, where the solid circle identifies the start position and the dashed circle identifies the target.
Input
The first line contains the value of n followed by a n × n matrix depicting the board configuration.
Output
The output consists of a single integer, which is the number of paths from the upper left corner to the lower right corner.
Example
Input: 4 2331 1213 1231 3110 Output: 3
Input: 4 3332 1213 1232 2120 Output: 0
Input: 5 11101 01111 11111 11101 11101 Output: 7
Added by: | Infinity |
Date: | 2011-03-21 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ADA95 ASM32 ASM64 BASH CLPS CLOJURE LISP sbcl LISP clisp D ERL FSHARP FORTRAN GO ICON ICK LUA NEM NICE OCAML PIKE PRLG-swi SCM guile SCM qobi ST TCL WHITESPACE |
hide comments
|
|||||||
2011-03-22 09:39:49 The Champ
are the numbers in each row separated by space? edit: answer to my question is NO. Last edit: 2011-03-22 12:13:56 |
|||||||
2011-03-22 08:08:11 Ravi Kiran
@All: I get accepted assuming the maximum value of N < 11. |
|||||||
2011-03-22 03:56:04 abhijith reddy d
@All: Dont not print '\n' in output. |
|||||||
2011-03-21 19:50:45 :D
Please don't use "exact judge" for this problem. It will just cause pointless WA's, since most people end a file with newlines. Use "standard judge", that ignores whitespace differences. It's perfect for almost all problems, certainly when output is/are number(s). Also please use rejudge when you change it. Last edit: 2011-03-21 19:55:09 |
|||||||
2011-03-21 19:29:20 The Champ
"board is filled with integers".. so if there are not digits than it is cheating :D test data has flaws |
|||||||
2011-03-21 19:09:02 Oleg
Please check test data. |
|||||||
2011-03-21 17:33:29 :D
What is the limit for N? Numbers in array are digits only, yes? Last edit: 2011-03-21 18:31:17 |