我猜中了开头,却没有猜中结局
****************after several days**********
来编辑结局了
在一行棋子中,一旦两个棋子挨着,先手必输(先手走几个对方走几个,紧挨着,一定会被逼到边缘),所以两个棋子挨着就代表这一行已定局(石子数为0)
所以就可以将两个棋子之间的距离当作石子数,引申为尼姆博弈进行异或
(注意距离要-1)
#include <iostream>
#include <stdio.h>
using namespace std;
int abst(int a,int b)
{
int t=a-b;
if(t>0)
return t;
else
return 0-t;
}
int main()
{
int n,m,a,b;
while(scanf("%d %d",&n,&m)!=EOF)
{
int ans=0;
while(n--)
{
scanf("%d %d",&a,&b);
ans^=(abst(a,b)-1);
}
if(ans==0)
printf("BAD LUCK!\n");
else
printf("I WIN!\n");
}
return 0;
}