$POJ1704\ Georgia\ and\ Bob$ 博弈论

正解:博弈论

解题报告:

传送门!

啊先放下翻译趴$QwQ$大概就是说,有一行$1\cdot n$的网格,每次可以向左移动若干步,不能越过前面已有棋子的格子就是了,然后谁不能动就输了,问最后是先手必胜还是后手必胜

然后这就是个阶梯游戏的变式昂$QwQ$

首先可以发现,当移动一个棋子的时候,相当于和后面那个棋子的距离变大,然后和前面那个棋子的距离变小,而且总量依然是不变的

于是考虑将所有棋子按升序排列,不难发现这题就变成了一个阶梯游戏?就因为只考虑间距,那每次移动都相当于是有一个减小了然后相邻那个增大了等大的数量,就可以理解为阶梯游戏中移动若干个棋子嘛,所以其实就是等价于阶梯游戏的

 

#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstdio>
using namespace std;
#define il inline
#define gc getchar()
#define ri register int
#define rb register bool
#define rc register char
#define rp(i,x,y) for(ri i=x;i<=y;++i)

const int N=1000+10;
int a[N],n;

il int read()
{
    rc ch=gc;ri x=0;rb y=1;
    while(ch!='-' && (ch>'9' || ch<'0'))ch=gc;
    if(ch=='-')ch=gc,y=0;
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;
    return y?x:-x;
}
int main()
{
    ri T=read();
    while(T--){ri as=0;n=read();rp(i,1,n)a[i]=read();sort(a+1,a+1+n);for(ri i=1;i<=n;i+=2)as^=(a[n-i+1]-a[n-i]-1);printf(as?"Georgia will win\n":"Bob will win\n");}
    return 0;
}
View Code

$mk$:$fft$&$ntt$&卷积&杜教筛

猜你喜欢

转载自www.cnblogs.com/lqsukida/p/10847615.html