两者间的间距就是可取石子数,因为对于行内黑白相连的局面该子游戏已经结束了
因为此时不管先手再怎么移都是必败,SG=0的终止态
/** @Date : 2017-10-14 21:46:21 * @FileName: HDU 1730 NIM模型.cpp * @Platform: Windows * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : https://github.com/ * @Version : $Id$ */ #include <bits/stdc++.h> #define LL long long #define PII pair #define MP(x, y) make_pair((x),(y)) #define fi first #define se second #define PB(x) push_back((x)) #define MMG(x) memset((x), -1,sizeof(x)) #define MMF(x) memset((x),0,sizeof(x)) #define MMI(x) memset((x), INF, sizeof(x)) using namespace std; const int INF = 0x3f3f3f3f; const int N = 1e5+20; const double eps = 1e-8; int main() { int n, m; while(cin >> n >> m) { int sg = 0; int a, b; for(int i = 0; i < n; i++) scanf("%d%d", &a, &b), sg ^= abs(a - b) - 1; printf("%s ", sg?"I WIN!":"BAD LUCK!"); } return 0; }