Submit | All submissions | Best solutions | Back to list |
TRAVERSE - Traverse through the board |
An n x 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
1. The number in any one square describes how far a step away from that location must be.
2. If the step size moves out of the game board, then that step is not allowed.
3. 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 x 4 board shown in Figure 1, where the solid circle identifies the start position and the dashed circle identifies the target. Figure 2 shows the three paths from the start to the target, with the irrelevant numbers in each removed.
Input
The first line contains the value of n followed by a nxn 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
|
|||||||
2014-09-29 09:41:49 Rahul Jain
constraints?? |
|||||||
2014-07-03 14:20:58 Manish Jindal
Tutorial stuff.. !! |
|||||||
2013-05-29 15:02:36 Francky
@muhammad zaakir mungrue : I've deleted your comments. Please see the notes below : no code here. Moreover your other posts were 'hum hum' not suitable at all. Please see comments below : "Don't print line feed" is recommended. I agree this output format is ridiculous, a judge that ignore extrawhitespace should be the rule for almost all problems. Edit : user banned by admin. Last edit: 2013-05-29 20:22:17 |
|||||||
2013-04-12 02:45:46 Jacob Plachta
Fantastic output format - it's so refreshing to come across a problem which saves me 2 keystrokes, doing away with the unnecessary newline often required by problems. |
|||||||
2013-01-13 14:23:17 SAHIL SAREEN
no image .. :C |
|||||||
2012-12-14 10:07:13 shivendra panicker
newline!! :p |
|||||||
2012-10-27 09:03:08 Ashok
nice prob, enjoyed solving :) |
|||||||
2012-08-22 17:48:49 BOND
R********N |