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:
hide comments
harish:
2014-08-03 14:11:26
make sure you check for the test case where the value at (0,0) is #. The answer is 0. |
|
ayush:
2014-07-17 11:44:11
Thanks Kumar Mrinal saved me from a TLE
|
|
|RAMSDEN|:
2014-06-30 14:09:29
nice problem
|
|
Akhilesh Anandh:
2014-04-17 09:55:41
Finally accepted! :) |
|
Tera:
2014-04-17 09:55:41
Easy |
|
Kumar Mrinal:
2014-04-17 09:55:41
Those gettin TLE read Aman Gupta's comment ... |
|
ɥsǝןǝǝu:
2014-04-17 09:55:41
No tricky case.. |
|
Tejas Joshi:
2014-04-17 09:55:41
Nice problem !!! |
|
Rohit:
2014-04-17 09:55:41
fanallyyyy....good question..:)) Last edit: 2012-12-24 08:46:40 |
|
Titas Skrebė:
2014-04-17 09:55:41
nice problem. |
Added by: | cegprakash |
Date: | 2012-10-14 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 GOSU |
Resource: | Inspired from http://codeforces.com/problemset/problem/115/B |