根据题目意思,现在假设先手即白棋向下走 x x x 步,那么后手黑棋也可以向下走 x x x 步,此时对于整个游戏而已没有任何的干涉。
同样的后上即黑棋向上走 x x x 步,白棋跟着向上走 x x x 步也并不影响结局。
所以取决定性的是白棋与黑棋之间的间隔。
假设间隔数量为 x x x ,显然任意一个棋子可以在间隔中走任意步数,所以对应的 s g [ x ] = x sg[x]=x sg[x]=x,最后直接求答案即可。
#include<bits/stdc++.h>
using namespace std;typedeflonglong ll;int a[105];intmain(){
int T, cas =0;scanf("%d",&T);while(T--){
int n;scanf("%d",&n);int ans =0;for(int i =1; i <= n;++i){
scanf("%d",&a[i]);}for(int i =1; i <= n;++i){
int t;scanf("%d",&t);
ans ^=(t - a[i]-1);}printf("Case %d: ",++cas);if(!ans)puts("black wins");elseputs("white wins");}return0;}