标签:des style blog color java os io strong 文件
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1130 Accepted Submission(s): 533
1 #include<iostream> 2 #include<string> 3 #include<cstdio> 4 #include<vector> 5 #include<queue> 6 #include<stack> 7 #include<set> 8 #include<algorithm> 9 #include<cstring> 10 #include<stdlib.h> 11 #include<math.h> 12 using namespace std; 13 #define ll __int64 14 string a[51]; 15 int n,m; 16 int can(int x,int y){ 17 if(x<n-1&&y<m-1&&a[x][y]==‘0‘&&a[x][y+1]==‘0‘&&a[x+1][y]==‘0‘&&a[x+1][y+1]==‘0‘) return 1; 18 else return 0; 19 } 20 void Go(int x,int y){ 21 a[x][y]=a[x][y+1]=a[x+1][y]=a[x+1][y+1]=‘1‘; 22 } 23 void Back(int x,int y){ 24 a[x][y]=a[x][y+1]=a[x+1][y]=a[x+1][y+1]=‘0‘; 25 } 26 int dfs(){ 27 for(int i=0;i<n;i++) 28 for(int j=0;j<m;j++) 29 if(can(i,j)){ 30 Go(i,j); 31 if(!dfs()){ 32 Back(i,j); 33 return 1; 34 } 35 Back(i,j); 36 } 37 return 0; 38 } 39 int main(){ 40 while(cin>>n>>m){ 41 for(int i=0;i<n;i++) cin>>a[i]; 42 if(dfs()) cout<<"Yes"<<endl; 43 else cout<<"No"<<endl; 44 } 45 }
标签:des style blog color java os io strong 文件
原文地址:http://www.cnblogs.com/ainixu1314/p/3934426.html