Poj 1321 棋盤問題

2021-09-23 23:04:43 字數 894 閱讀 1587

click here ~~

input

輸入含有多組測試資料。

每組資料的第一行是兩個正整數,n k,用乙個空格隔開,表示了將在乙個n*n的矩陣內描述棋盤,以及擺放棋子的數目。 n <= 8 , k <= n

當為-1 -1時表示輸入結束。

隨後的n行描述了棋盤的形狀:每行有n個字元,其中 # 表示棋盤區域, . 表示空白區域(資料保證不出現多餘的空白行或者空白列)。

output

對於每一組資料,給出一行輸出,輸出擺放的方案數目c (資料保證c<2^31)。

sample input21

#..#44

...#

..#.

.#..

#...

-1 -1

sample output

21

題目大意:這是中文題。。。應該能懂哈。。。。

解題思路:激素簡單的dfs 搜尋:

這個不太好說,具體上**吧:

#include 

#include

#include

using

namespace

std;

const

int maxn = 10;

int n,k,cnt;

bool fac[maxn];

char

map[maxn][maxn];

void dfs(int r, int num)

if(r > n)

return ;

for(int i=1; i <= n; i ++)

}dfs(r+1,num);

}int main()

POJ 1321 棋盤問題

time limit 1000ms memory limit 10000k total submissions 7007 accepted 3390 description 在乙個給定形狀的棋盤 形狀可能是不規則的 上面擺放棋子,棋子沒有區別。要求擺放時任意的兩個棋子不能放在棋盤中的同一行或者同一列...

poj 1321 棋盤問題

棋盤問題 time limit 1000ms memory limit 10000k total submissions 15365 accepted 7600 description 在乙個給定形狀的棋盤 形狀可能是不規則的 上面擺放棋子,棋子沒有區別。要求擺放時任意的兩個棋子不能放在棋盤中的同一...

POJ 1321 棋盤問題

找到第乙個有 的行開始回溯就可以了 include include using namespace std const int maxn 9 char board maxn maxn bool c maxn int ans,n,k void backtracking int curi,int cnt...