II play with GG

Posted dwvictor

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了II play with GG相关的知识,希望对你有一定的参考价值。

https://ac.nowcoder.com/acm/contest/338/I

题解:首先轮到出手的时候如果在(0,0)上肯定是输的,而(0,1)(1,0)(0,2)(2,0)(1,1)肯定是赢的;

往上递推,某一个(x,y)如果可以走的(x-1,y)(x,y-1)(x-1,y-1)三点都是必输的,那么在(x,y)的人必输。

 
借大佬代码一用

 

技术分享图片
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=1000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,q,ans;
bool a[N][N];
char str;
int main()
{
#ifdef DEBUG
    freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout);
#endif
    scanf("%d%d",&n,&m);
    a[0][0]=0;
    a[1][0]=a[0][1]=1;
    a[1][1]=1;
    for(int i=0; i<=n; i++)
    {
        for(int j=0; j<=m; j++)
        {
            if(i-1>=0&&j-1>=0)
            {
                if(a[i][j-1]&&a[i-1][j]&&a[i-1][j-1])
                    a[i][j]=0;
                else
                    a[i][j]=1;
            }
            else if(i-1>=0)
            {
                if(a[i-1][j])
                    a[i][j]=0;
                else
                    a[i][j]=1;
            }
            else if(j-1>=0)
            {
                if(a[i][j-1])
                    a[i][j]=0;
                else
                    a[i][j]=1;
            }
        }

    }

    if(a[n][m])
    {
        cout << "ii" << endl;
    }
    else
    {
        cout << "gg" << endl;
    }
    //cout << "Hello world!" << endl;
    return 0;
}
View Code

 

 待补充

技术分享图片
#include<bits/stdc++.h>
using namespace std;
int main(){
    int m,n;
    cin >> m >>n;
    if(min(m,n)%2) cout <<"ii";
    else if ((max(m,n)-min(m,n))%2==0) cout <<"gg";
    else cout <<"ii";
    
    return 0; 
}
View Code

 

以上是关于II play with GG的主要内容,如果未能解决你的问题,请参考以下文章

json 可视代码工作室Angular with Firebase片段

[Codeforces Round #522 (Div. 2, based on Technocup 2019 Elimination Round 3)][C. Playing Piano](代码片段

A - Playing with Paper (CodeForces - 527A)

吉司机线段树思路整理[bzoj4355 Play with sequence]

HDU 3487Play with Chain Splay

尝试保存凭据时,使用Google Drive API库和Play with Java会冻结/锁定应用程序