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 |
为什么tle呀,大牛们,帮我看看#include<iostream> using namespace std; int n,cnt; char map[8][8]; bool row[8],col[8]; void solve(int m,int k) { int i; for(i=0;i<n;i++) { if(map[m][i]=='#'&&!row[m]&&!col[i]) { row[m]=1; col[i]=1; k--; if(m+1<n&&k>0) solve(m+1,k); if(k==0) cnt++; k++; row[m]=0; col[i]=0; if(m+1<n) { solve(m+1,k); } } } } int main() { int i,j,k; while((cin>>n>>k)&&n!=-1) { cnt=0; memset(row,0,sizeof(row)); memset(col,0,sizeof(col)); for(i=0;i<n;i++) for(j=0;j<n;j++) cin>>map[i][j]; solve(0,k); cout<<cnt<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator