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 |
WA 到我死,能找到的测试数据全过,大牛们看看这到底是为什么?#include <iostream> using namespace std; int data[17][301]; int row; int ans[301]; int m,n; int DFS(int row) { int f=0; int fans[301]; int sans[301]; if(row>m) return 0; for(int i=1;i<=n;i++) { sans[i]=ans[i]; ans[i]=ans[i]+data[row][i]; if(ans[i]==0) f=1; if(ans[i]>1) return 0; } if(!f) return 1; for(int i=row+1;i<=m;i++) { for(int j=1;j<=n;j++) fans[j]=ans[j]; if(DFS(i)) return 1; else { for(int j=1;j<=n;j++) ans[j]=fans[j]; } } for(int i=1;i<=n;i++) ans[i]=sans[i]; return DFS(row+1); } int main() { while( cin>>m>>n ) { for(int i=1;i<=m;i++) for(int j=1;j<=n;j++) cin>>data[i][j]; memset(ans,0,sizeof(ans)); if(DFS(1)) cout<<"Yes, I found it"<<endl; else cout<<"It is impossible"<<endl; } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator