#t348. 棋盘问题
棋盘问题
Chessboard Placement
Problem Background
Special for beginners, ^_^
Problem Description
Place indistinguishable pieces on a given-shaped chessboard (the shape may be irregular). The requirement is that no two pieces may be placed in the same row or the same column of the board. Write a program that, given the shape and size of the board, computes the number of all feasible placements of pieces.
Input Format
The input contains multiple test cases.
Each test case's first line contains two positive integers , separated by a space, meaning that the board is described within an matrix and pieces are to be placed .
The input ends when -1 -1 is given.
The following lines describe the board shape: each line has characters, where # denotes a board cell and . denotes a blank cell (the data guarantees there are no extra blank rows or columns).
Output Format
For each test case, output one line with the number of placement schemes (the data guarantees ).
Sample Input
2 1
#.
.#
4 4
...#
..#.
.#..
#...
-1 -1
Sample Output
2
1
Constraints
1s, 1024KiB for each test case.