|
<p> |
|
Al is the proprietor of Al's Awesome and Amazing Amusement Arcade, |
|
called AAAAAA by some, AAaAAA by others, AAAAA by others still, and |
|
alternately A<sup>5</sup> or A<sup>6</sup> by math majors. |
|
</p> |
|
|
|
<p> |
|
The problem with operating such a spectacular business is managing the line of |
|
people waiting to get in. City by-laws prevent people from loitering on Al's |
|
property, so anybody who wants to experience the wonders Al has in store has |
|
to queue in the parking lot. Not wanting to turn people away, Al is interested |
|
in cramming as many hapless souls into the parking lot as he can. However, |
|
customers are a whiny bunch, and refuse to stand in any queue that makes too |
|
many detours before getting to the entrance. |
|
</p> |
|
|
|
<p> |
|
You can imagine that the parking lot is a grid, with the Arcade's entrance in |
|
the upper-left corner. All queues must begin here. There may be cars in the |
|
parking lot, denoted '#'. Customers refuse to queue on top of cars. All other |
|
cells will contain '.'. Due to customer complaints, all queues must generally |
|
extend only rightwards and downwards. However, Al's clientele is not entirely |
|
unreasonable, so a queue may have a single contiguous section that runs |
|
upwards, or a single contiguous section that runs leftwards, but not both. |
|
Queues only extend in these four directions (i.e., not diagonally). |
|
</p> |
|
|
|
<p> |
|
There is only room for one customer in each empty space. Each pair of consecutive customers in the queue must stand in adjacent spaces, i.e. there can't be any gaps in the queue. |
|
</p> |
|
|
|
|
|
<h3>Input</h3> |
|
<p> |
|
The first line of the input consists of a single integer <strong>T</strong>, the number of test |
|
cases. <br /> |
|
Each test case begins with a line containing two integers, <strong>N</strong> and <strong>M</strong>, the number of rows and columns in the lot's grid.<br /> |
|
The next <strong>N</strong> lines each contain a string with exactly <strong>M</strong> characters, where the <strong>i</strong>th line correspond to the <strong>i</strong>th row in the grid. <br /> |
|
</p> |
|
|
|
<h3>Output</h3> |
|
<p> |
|
For each test case <strong>i</strong> numbered from 1 to <strong>T</strong>, output "Case #<strong>i</strong>: ", followed by the size of the largest queue starting in the top left corner that Al can fit into his parking lot. |
|
</p> |
|
|
|
<h3>Constraints</h3> |
|
<p> |
|
1 ≤ <strong>T</strong> ≤ 20 <br /> |
|
1 ≤ <strong>N</strong>, <strong>M</strong> ≤ 500 <br /> |
|
Each character in the grid will be either '.' or '#'. <br /> |
|
The character in the upper left corner will always be '.' <br /> |
|
</p> |
|
|