|
||||||||||
MountainTime Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 572 Accepted Submission(s): 177 Problem Description Zhu found a map which is a $N * M$ rectangular grid.Each cell has a height and there are no two cells which have the same height. But this map is too old to get the clear information,so Zhu only knows cells which are valleys. A cell is called valley only if its height is less than the heights of all its adjacent cells.If two cells share a side or a corner they are called adjacent.And one cell will have eight adjacent cells at most. Now give you $N$ strings,and each string will contain $M$ characters.Each character will be '.' or uppercase 'X'.The j-th character of the i-th string is 'X' if the j-th cell of the i-th row in the mountain map is a valley, and '.' otherwise.Zhu wants you to calculate the number of distinct mountain maps that match these strings. To make this problem easier,Zhu defines that the heights are integers between $1$ and $N*M$.Please output the result modulo $772002$. Input The input consists of multiple test cases. Each test case begins with a line containing two non-negative integers $N$ and $M$. Then $N$ lines follow, each contains a string which contains $M$ characters. $(1 \leq N \leq 5,1 \leq M \leq 5)$. Output For each test case, output a single line "Case #x: y", where x is the case number, starting from 1. And y is the answer after module 772002. Sample Input
Sample Output
Author UESTC Source | ||||||||||
|