F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Game of Eliminate

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 438    Accepted Submission(s): 47


Problem Description
Little Ruins is a studious boy, but in rest time, he will play some little game.

Today he found a game of eliminate: there is $N \times M$ tiles which only contains '#' and '*', you have two patterns to eliminate tiles:

:.

and

.:

Each step you can use a pattern and eliminate tiles on the bottom two lines. After each step,the tiles above eliminated tiles will fall down.

Your goal is to eliminate all '*' tiles, please calculate the minimum steps.
 

Input
First line contains an integer $T$, which indicates the number of test cases.

Every test case begins with two integers $N$ and $M$, which indicates the size of tiles.

In the following N lines, every line contains $M$ characters means the type of tiles.

Limits
$1 \leq T \leq 50$.
$1 \leq N \leq 2000$
$2 \leq M \leq 2000$.
For 80% of the use cases, $1 \leq N, M \leq 100$ holds.
 

Output
For every test case, you should output 'Case #x: y', where x indicates the case number and counts from 1 and y is the result.
 

Sample Input
1 3 2 #* *# ##
 

Sample Output
Case #1: 2
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-13 12:54:45, Gzip enabled