TOURIST  Tourist
A lazy tourist wants to visit as many interesting locations in a city as possible without going one
step further than necessary. Starting from his hotel, located in the northwest corner of city, he
intends to take a walk to the southeast corner of the city and then walk back. When walking to
the southeast corner, he will only walk east or south, and when walking back to the northwest
corner, he will only walk north or west. After studying the city map he realizes that the task is not
so simple because some areas are blocked. Therefore he has kindly asked you to write a program
to solve his problem.
Given the city map (a 2D grid) where the interesting locations and blocked areas are marked,
determine the maximum number of interesting locations he can visit. Locations visited twice are
only counted once.
Input
The first line in the input contains the number of test cases (at most 20). Then follow the cases.
Each case starts with a line containing two integers, W and H (2 ≤ W , H ≤ 100), the width and
the height of the city map. Then follow H lines, each containing a string with W characters with
the following meaning:
. Walkable area
* Interesting location (also walkable area)
# Blocked area
You may assume that the upperleft corner (start and end point) and lowerright corner (turning
point) are walkable, and that a walkable path of length H + W − 2 exists between them.
Output
For each test case, output a line containing a single integer: the maximum number of interesting locations the lazy tourist can visit.
Example
Input: 2 9 7 *........ .....**#. ..**...#* ..####*#. .*.#*.*#. ...#**... *........ 5 5 .*.*. *###. *.*.* .###* .*.*. Output: 7 8
hide comments
chetan4060:
20180202 12:15:22
very good question:) 

danish4200:
20170929 11:22:40
Nice problem.Learnt something new. 

hunter17:
20170304 08:59:36
Can anyone explain how the answer to following test case could be 4????


weramajstor:
20161004 02:33:08
Very interesting problem,huge upgrade on the problem in which you just have to go from the topleft to the bottomright corner. 

Shubham Gupta:
20160705 10:59:23
Solving this problem was totally worth it! :D


Annu Purohit:
20160610 18:58:35
Accepted after trying a whole day!


sdnr1:
20160303 14:23:54
The following test case is mentioned in an earlier comment. Why is it said to be an invalid test case


rjgames:
20160223 05:14:56
4 4


vijay77794:
20160111 06:10:17
atlast done....... :0 

anshal dwivedi:
20160110 09:34:28
Last edit: 20160110 10:00:02 
Added by:  Daniel Gómez Didier 
Date:  20081118 
Time limit:  0.370s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ERL JSRHINO NODEJS PERL6 VB.NET 
Resource:  2007 PUJ  Circuito de Maratones ACIS / REDIS 