【HDOJ】1760 A New Tetris Game

博弈,主要是求SG值。终于做出点儿感觉。

 1 /* 1760 */
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <cstdlib>
 5 
 6 #define MAXN 55
 7 
 8 char map[MAXN][MAXN];
 9 int n, m;
10 
11 int cal_SG() {
12     int i, j, k, r, p;
13     
14     for (i=0; i<n-1; ++i) {
15         for (j=0; j<m-1; ++j) {
16             if (map[i][j]=='0' && map[i][j+1]=='0' && map[i+1][j]=='0' && map[i+1][j+1]=='0') {
17                 map[i][j] = map[i][j+1] = map[i+1][j] = map[i+1][j+1] = '1';
18                 k = cal_SG();
19                 map[i][j] = map[i][j+1] = map[i+1][j] = map[i+1][j+1] = '0';
20                 if (k == 0)
21                     return 1;
22             }
23         }
24     }
25     return 0;
26 }
27 
28 int main() {
29     int i, j, k;
30     
31     #ifndef ONLINE_JUDGE
32         freopen("data.in", "r", stdin);
33     #endif
34     
35     while (scanf("%d %d", &n, &m) != EOF) {
36         for (i=0; i<n; ++i)
37             scanf("%s", map[i]);
38         if (cal_SG() == 0)
39             puts("No");
40         else
41             puts("Yes");
42     }
43     
44     return 0;
45 }

 

posted on 2015-01-28 22:57  Bombe  阅读(182)  评论(0编辑  收藏  举报

导航