
做一下差分之后,把每个位置的差分数看成这个位置有多少个石子,于是每次操作就是选一个有石子的位置并把这个位置的石子移到后面的位置(如果这个位置已经是最后了那么直接扔掉)。
所以就是带权石子问题了,最后判一下奇偶性就行了23333
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,now,pre,ans;
int main(){
scanf("%d",&n),pre=0;
for(int i=1;i<=n;pre=now,i++){
scanf("%d",&now);
ans^=(((now-pre)&1)&((n-i+1)&1));
}
if(ans) puts("Alice");
else puts("Bob");
return 0;
}
原文:https://www.cnblogs.com/JYYHH/p/9066432.html