zoukankan      html  css  js  c++  java
  • hdu 1760 A New Tetris Game 夜

    http://acm.hdu.edu.cn/showproblem.php?pid=1760

    dfs + 博弈

    代码:

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<string>
    #include<vector>
    #include<queue>
    #include<map>
    #include<stack>
    #include<algorithm>
    #include<cmath>
    
    using namespace std;
    //#pragma comment(linker,"/STACK:1000000000,1000000000")
    
    #define LL long long
    
    const int N=55;
    char a[N][N];
    int n,m;
    int dfs()
    {/*
        for(int i=0;i<n;++i)
        {
            for(int j=0;j<m;++j)
            cout<<a[i][j]<<" ";
            cout<<endl;
        }*/
        int k=0;
        for(int i=1;i<n;++i)
        {
            for(int j=0;j<m-1;++j)
            {
                if(a[i][j]=='1'||a[i-1][j]=='1'||a[i][j+1]=='1'||a[i-1][j+1]=='1')
                continue;
                a[i][j]='1';a[i-1][j]='1';a[i][j+1]='1';a[i-1][j+1]='1';
                if(dfs()==0)
                k=1;
                a[i][j]='0';a[i-1][j]='0';a[i][j+1]='0';a[i-1][j+1]='0';
                if(k)
                break;
            }
            if(k)
            break;
        }
        return k;
    }
    int main()
    {
        //freopen("data.txt","r",stdin);
        while(scanf("%d %d",&n,&m)!=EOF)
        {
            getchar();
            for(int i=0;i<n;++i)
            {
                gets(a[i]);
            }
            if(dfs())
            printf("Yes\n");
            else
            printf("No\n");
        }
        return 0;
    }
    
  • 相关阅读:
    Python 从入门到实践
    Python 斐波那契数列
    Python 纸牌游戏
    Python hangman小游戏
    BC #49 1001 Untitled
    BC#50 1003 The mook jong
    BC #50 1001 Distribution money
    vector
    stack
    queue
  • 原文地址:https://www.cnblogs.com/liulangye/p/2726821.html
Copyright © 2011-2022 走看看