Submit | All submissions | Best solutions | Back to list |
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: | All except: ASM64 GOSU |
Resource: | Inspired from http://codeforces.com/problemset/problem/115/B |
hide comments
|
||||||||||
2017-05-24 14:51:35 Nafis Islam
[spoiler] + [spoiler] = ac :D Last edit: 2017-08-02 13:11:28 |
||||||||||
2017-04-17 08:42:17
Thanks @Ruchir Thaman If the box 0,0 is blue (#), your answer should be 0. Also, what is the point of removing spoilers from comments when the tag gives it away? |
||||||||||
2017-02-25 06:03:50 gautam
nice one..:) |
||||||||||
2017-01-16 20:58:41
Finally solved it. :-D Thank you @cegprakash senior! [Spoiler]-> TLE Plain [Spoiler] -> AC! Great problem. Last edit: 2017-01-17 04:01:09 |
||||||||||
2016-12-28 20:29:19
Finally AC !!! :) Nice problem for [spoiler] beginners Last edit: 2016-12-28 21:08:32 |
||||||||||
2016-10-17 20:26:41
100th |
||||||||||
2016-07-20 11:48:55
Loved solving it! :D |
||||||||||
2016-07-05 22:47:21
my 50th [spoiler] :) Last edit: 2016-07-29 22:15:34 |
||||||||||
2016-04-19 23:51:44 Deepak
silly mistake gave me 2 WAs.nice one to do ;) |
||||||||||
2016-02-21 17:55:37 Vivek Mangal
[spoiler] and accepted Last edit: 2016-07-29 22:15:55 |