【题解】Cutting Game

【题解】Cutting Game

vjudge

谈谈对\(sg\)函数的理解?

浅谈公平组合游戏IGC

//@winlere
#include<cstring>
#include<cstdio>
using namespace std;  typedef long long ll;
const int maxn=201;
int temp[maxn];
int sg[maxn][maxn],a,b;

int main(){
      for(register int n=2;n<=200;++n)
	    for(register int m=2;m<=200;++m){
		  memset(temp,0,sizeof temp);
		  for(register int p=2;n-p>=2;++p)temp[sg[p][m]^sg[n-p][m]]=1;
		  for(register int p=2;m-p>=2;++p)temp[sg[n][p]^sg[n][m-p]]=1;
		  for(register int p=0;p<=200;++p)
			if(!temp[p]) {sg[n][m]=p;break;}
	    }
      while(~scanf("%d %d",&a,&b)) sg[a][b]?puts("WIN"):puts("LOSE");
      return 0;
}

posted @ 2019-05-11 12:05  谁是鸽王  阅读(410)  评论(1编辑  收藏  举报