#P3160. [CQOI2012] 局部极小值
[CQOI2012] 局部极小值
Description
There is an by integer matrix in which each integer between and appears exactly once.
If a cell is smaller than all of its adjacent cells (adjacent means sharing a side or a vertex), we say this cell is a local minimum. Given the positions of all local minima, your task is to determine how many matrices are possible.
Output the answer modulo .
Input Format
The first line contains two integers and , the number of rows and columns.
Each of the next lines contains characters. For each from to , the -th line’s -th character represents whether the cell at row and column is a local minimum. Each character is either X or ., where X denotes a local minimum and . denotes a non-local minimum.
Output Format
Output a single line containing the number of possible matrices modulo .
3 2
X.
..
.X
60
Hint
- Constraints
- For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号