Public submissions
Source code of every submission to this problem in this contest will be visible for everyone since 4012-10-16 21:00:00.

MAXWOODS - MAXIMUM WOOD CUTTER

Problem Statement:


The image explains it all. You initially step at 0,0 facing right. At each step you can move according to the conditions specified in the image. You cannot step into the blocked boxes (in blue). Find the maximum number of trees you can cut.

Input:

The first line consists of an integer t, the number of test cases. For each test case the first line consists of two integers m and n, the number of rows and columns. Then follows the description of the matrix M.

M[i][j]=’T’ if the region has a tree.

M[i][j]=’#’ if the region is blocked.

M[i][j]=’0’ (zero) otherwise.

Output:

For each test case find the maximum trees that you can cut.

Input Constraints:

1<=t<=10

1<=m,n<=200

Example:

Sample Input:

4
5 5
0TTTT
T#T#0
#TT#T
T00T0
T0#T0
1 1
T
3 3
T#T
TTT
T#T
1 1
#

Sample Output:

8
1
3
0

Solution for test case #1:


Added by:cegprakash
Date:2012-10-14
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:ADA95 ASM32 GAWK C CSHARP C++ 4.3.2 CPP14-CLANG C99 CLPS CLOJURE LISP sbcl LISP clisp D-CLANG ERL FSHARP FORTRAN GO HASK ICON ICK JS-RHINO JS-MONKEY LUA NICE NIM NODEJS OCAML PAS-FPC PERL PERL6 PHP PICO PIKE PRLG-swi PYTHON PYPY PYTHON3 RUBY SCM guile SCM qobi SED TCL VB.NET WHITESPACE
Resource:Inspired from http://codeforces.com/problemset/problem/115/B
Public source code since: 4012-10-16 21:00:00

hide comments
2012-10-16 17:35:12 Janani
Okay i get it. :)

Last edit: 2012-10-16 17:36:15
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.