zoukankan      html  css  js  c++  java
  • hdu1760博弈SG

    A New Tetris Game

    Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 929    Accepted Submission(s): 422

    Problem Description
    曾经,Lele和他姐姐最喜欢,玩得最久的游戏就是俄罗斯方块(Tetris)了。 渐渐得,Lele发觉,玩这个游戏只需要手快而已,几乎不用经过大脑思考。 所以,
    Lele想出一个新的玩法。
    Lele和姐姐先拿出一块长方形的棋盘,这个棋盘有些格子是不可用的,剩下的都是可用的。Lele和姐姐拿出俄罗斯方块里的正方形方块(大小为2*2的正方形
    方块)轮流往棋盘里放,要注意的是,放进去的正方形方块不能叠在棋盘不可用的格子上,也不能叠在已经放了的正方形方块上。 到最后,谁不能再放正方
    形方块,谁就输了。
    现在,假设每次Lele和姐姐都很聪明,都能按最优策略放正方形,并且每次都是Lele先放正方形,你能告诉他他是否一定能赢姐姐吗?
     
    Input
    本题目包含多组测试,请处理到文件结束。 每组测试第一行包含两个正整数N和M(0<N*M<50)分别代表棋盘的行数和列数。 接下来有N行,每行M个0或1
    的数字代表整个棋盘。 其中0是代表棋盘该位置可用,1是代表棋盘该位置不可用
    你可以假定,每个棋盘中,0的个数不会超过40个。
     
    Output
    对于每一组测试,如果Lele有把握获胜的话,在一行里面输出"Yes",否则输出"No"。
     
    Sample Input
    4 4 0000 0000 0000 0000 4 4 0000 0010 0100 0000
     
    Sample Output
    Yes No

     想不到是爆搜+SG值(其实是P,N分析):

     1 #include <iostream>
     2 #include <stdio.h>
     3 #include <algorithm>
     4 #include <string.h>
     5 #include <math.h>
     6 #include <vector>
     7 #include <stack>
     8 #include <queue>
     9 using namespace std;
    10 #define ll long long int
    11 int n,m;
    12 int fun(int b[][50])
    13 {
    14     int c[50][50];
    15     int i,j;
    16     for(i=0;i<n-1;i++)
    17     for(j=0;j<m-1;j++)
    18     {
    19         if(!b[i][j]&&!b[i+1][j]&&!b[i+1][j+1]&&!b[i][j+1])
    20         {
    21             int t,r;
    22             for(r=0;r<n;r++)
    23             for(t=0;t<m;t++)
    24             c[r][t]=b[r][t];
    25             c[i][j]=c[i+1][j]=c[i+1][j+1]=c[i][j+1]=1;
    26             if(!fun(c))return 1;
    27         }
    28     }
    29     return 0;
    30 }
    31 int main()
    32 {
    33     while(cin>>n>>m)
    34     {
    35         char a[50][51];
    36         int i,j;
    37         for(i=0;i<n;i++)
    38         {
    39             cin>>a[i];
    40         }
    41         int b[50][50];
    42         for(i=0;i<n;i++)
    43         {
    44             for(j=0;j<m;j++)
    45             {
    46                 b[i][j]=a[i][j]-'0';
    47             }
    48         }
    49         if(fun(b))
    50         cout<<"Yes"<<endl;
    51         else cout<<"No"<<endl;
    52     }
    53 }
    View Code
  • 相关阅读:
    免费素材:推荐最新的免费图标字体Sosa
    如何选择Javascript模板引擎(javascript template engine)?
    名片设计最佳实践和技巧分享
    帮助你生成翻页效果的jQuery插件 bookblock
    网页网站收集
    main xml信息
    c# winrar 打包
    c# 压缩文件
    前端工程师
    fash 3D 游戏
  • 原文地址:https://www.cnblogs.com/ERKE/p/3263593.html
Copyright © 2011-2022 走看看