POJ-1321-棋盘问题
来源:互联网 发布:淘宝雪纺衫花色衬衣 编辑:程序博客网 时间:2024/06/02 06:41
解题报告:
1、逐行放置,则仅需考虑列是否冲突。
2、注意在出口处恢复被修改的值。
AC代码:
#include <iostream>#include <cstring>using namespace std;int n, k, ans;int col[10];char chess[10][10];void dfs(int row, int num){if(num == k){ans++;return;}for(int i = row+1; i < n; i++)for(int j = 0; j < n; j++)if(chess[i][j]=='#' && !col[j]){col[j] = 1;dfs(i, num+1);col[j] = 0;}}int main(void){while(cin>>n>>k && n!=-1){ans = 0;memset(col, 0, sizeof(col));for(int i = 0; i < n; i++)cin >> chess[i];dfs(-1, 0);cout << ans << endl;}return 0;}
0 0
- POJ 1321 棋盘问题
- poj 1321 棋盘问题
- poj 1321 棋盘问题
- Poj 1321 棋盘问题
- POJ 1321 棋盘问题
- POJ 1321 棋盘问题
- POJ-1321-棋盘问题
- poj 1321棋盘问题
- POJ 1321 棋盘问题
- poj 1321 棋盘问题
- POJ 1321 棋盘问题
- poj 1321 棋盘问题
- poj 1321 棋盘问题
- poj 1321 棋盘问题
- poj 1321 棋盘问题
- POJ 1321 - 棋盘问题
- poj 1321棋盘问题
- POJ 1321 棋盘问题
- A + B Problem
- \\w+\\|\\d+ 这个在java里啥意思啊?
- Android之简单Socket编程
- GridControl详解(一)原汁原味的表格展示
- C语言知识查漏补缺与心得体会(1)
- POJ-1321-棋盘问题
- 编译指令page覆盖meta设置
- 更新ZTE N880E手机的MAC地址
- 栈的应用
- 5.Maven和Eclipse整合(两种方式进行插件的安装),Maven相关设置,Eclipse下创建Maven项目
- C#PopStar【消除类】
- (SRC)基于稀疏表示的人脸识别
- poj 1328Radar Installation
- GridControl详解(二)表格的列名配置