poj 1321
来源:互联网 发布:什么软件下歌不要钱 编辑:程序博客网 时间:2024/04/30 13:05
dfs
#include<iostream>#include<cstring>#include<algorithm>using namespace std;char chess[10][10];int col[10];int n,m,ans;void dfs(int row,int num){int i,j;if(num==m){ans++;return;}for(i=row+1;i<=n;i++)for(j=1;j<=n;j++)if(chess[i][j]!='.' && !col[j]){col[j]=1;dfs(i,num+1);col[j]=0;}}int main(){int i;while(cin>>n>>m){ans=0;if(n==-1 && m==-1)break;memset(col,0,sizeof(col));for(i=1;i<=n;i++)cin>>chess[i]+1;dfs(0,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
- 你不知道的JavaScript--Item8 函数,方法,构造函数调用
- 查询所有产品的原价的SQL
- 周末小计
- SQL LCASE() 函数
- Magento查询历史完成订单的产品销售价格
- poj 1321
- 谈ubuntu12.04 64bit安装hadoop2.2.0的方法
- Jquery实现表单的动态验证
- 网易javascript解答
- 也谈文件的多线程下载
- SQL MID() 函数
- 一位前辈的作品 - MMPopupView(弹出框组件
- Django学习指南之Model层
- java中的io——读写大文件(二)