MAXWOODS - MAXIMUM WOOD CUTTER
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.
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.
For each test case find the maximum trees that you can cut.
4 5 5 0TTTT T#T#0 #TT#T T00T0 T0#T0 1 1 T 3 3 T#T TTT T#T 1 1 #
8 1 3 0
Solution for test case #1:
silly mistake gave me 2 WAs.nice one to do ;)
[spoiler] and acceptedLast edit: 2016-07-29 22:15:55
3 attempts still getting WA
simple problem ..after this try BYTESM2. similar concept .
just use desi jugaad ..
nice ques...finally accepted..:)
I don't know what is wrong in my code...someone please check it or give me some tricky cases.
If the initial position contains a blocked box,the answer has to be zero,costed me 2 WA.
Can't believe it turned out to be THIS easy :D
good [spoiler removed] for beginners :)Last edit: 2014-11-12 00:40:37