标签:put for name other ret 姐姐 code 策略 names
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1457 Accepted Submission(s): 713
题意:给你一个n*m的矩形,0表示空着的,1反之,现在两个人轮流放2*2的矩形,谁不能放了,谁就输了。
题解:每一个状态的NP态由后继状态决定,后继状态存在P态既为N态,后继状态全为N态既为P态
后继状态的状态同上,可以用递归暴力计算
#include<bits/stdc++.h> #define mes(x) memset(x, 0, sizeof(x)); #define ll __int64 const long long mod = 1e9+7; const int MAX = 0x7ffffff; using namespace std; int n,m, a[100][100]; //NP态 int dfs(){ for(int i=1;i<n;i++) for(int j=1;j<m;j++) if(a[i][j]==0&&a[i-1][j-1]==0&&a[i-1][j]==0&&a[i][j-1]==0){ a[i][j] = a[i-1][j-1] = a[i][j-1] = a[i-1][j] = 1; if(dfs() == 0) { a[i][j] = a[i-1][j-1] = a[i][j-1] = a[i-1][j] = 0; return 1; } a[i][j] = a[i-1][j-1] = a[i][j-1] = a[i-1][j] = 0; } return 0; } int main() { while(~scanf("%d%d", &n, &m)){ for(int i=0;i<n;i++) for(int j=0;j<m;j++) scanf("%1d", &a[i][j]); printf("%s\n", dfs()?"Yes":"No"); } return 0; }
标签:put for name other ret 姐姐 code 策略 names
原文地址:http://www.cnblogs.com/Noevon/p/6241394.html