Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
水过。。。。//============================================================================ // Name : PKU-ACM.cpp // Author : Jarvis // Version : // Copyright : Your copyright notice // Description : Hello World in C, Ansi-style //============================================================================ #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <algorithm> #include <deque> #include <queue> #include <vector> using namespace std; #define __int64 long long char map[8][8]; int can=0; int res=0; void dfs(int n,int k,int l) { if (l>=n||k<=0) return; for(int i=0;i<n;++i) { if(map[l][i]=='#'&&(can&(1<<i))==0) { can|=(1<<i); if(k-1==0) ++res; else dfs(n,k-1,l+1); can&=~(1<<i); } } if(k<n-l) dfs(n,k,l+1); } int main() { int n,k; while(scanf("%d%d",&n,&k)&&n!=-1&&k!=-1) { for(int i=0;i<n;++i) scanf("%s",map[i]); res=0; can=0; dfs(n,k,0); printf("%d\n",res); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator