poj1321 棋盘问题 dfs
2014-05-11 16:12
309 查看
题目链接:http://poj.org/problem?id=1321
poj少有的中文题目,很嗨皮
直接上代码:
poj少有的中文题目,很嗨皮
直接上代码:
///2014.3.30 ///poj1321 #include <iostream> #include <cstdio> using namespace std; int N,K; bool board[10][10]; bool used[10]; int C; void init(){ char temp; for(int i=1 ; i<=N ; i++){ used[i] = false; for(int j=1 ; j<=N ; j++){ cin>>temp; if( temp=='#' ) board[i][j] = true; else board[i][j] = false; } } C = 0; } void dfs(int r,int num){ if( num==K ){ C++; return; } if( r>N ) return; for(int i=1 ; i<=N ; i++){ if( board[r][i] && !used[i] ){ used[i] = true; dfs(r+1,num+1); used[i] = false; } } dfs(r+1,num); } int main() { // freopen("in","r",stdin); // freopen("out","w",stdout); while( cin>>N>>K && N!=-1 && K!=-1 ){ init(); dfs(1,0); cout<<C<<endl; } return 0; }
相关文章推荐
- poj 1321 棋盘问题 dfs暴力
- poj 1321 棋盘问题(dfs)
- POJ 1321 棋盘问题(dfs)
- POJ 1321 棋盘问题(DFS板子题,简单搜索练习)
- Poj1321 棋盘问题 DFS
- poj 1321 -- 棋盘问题 (DFS)
- Poj 1321 棋盘问题(DFS)
- POJ 1321-棋盘问题(dfs)
- POJ1321 棋盘问题(DFS||状压DP)
- poj 1321 :棋盘问题 (dfs)
- poj 1321 棋盘问题 (简单的DFS)
- POJ 1321 棋盘问题(DFS)
- poj 1321 棋盘问题 dfs 回溯
- POJ 1321 棋盘问题(DFS)
- dfs-poj-1321棋盘问题
- POJ 1321 棋盘问题(棋盘DFS)
- POJ - 1321棋盘问题(dfs)
- 棋盘问题 (dfs) POJ - 1321
- POJ - 1321 棋盘问题(回溯 DFS)
- POJ 1321 棋盘问题(DFS)