题解 [ARC137C] Distinct Numbers
然而赛时并不会
考虑证明当 \(A_{n}\geqslant A_{n-1}+2\) 时先手必胜
若将 \(A_n\) 移至 \(A_{n-1}\) 左边形成的局面都是先手必胜,则可以移到 \(A_{n-1}+1\),这样对手接下来就只能留给你一个必胜局面了
若将 \(A_n\) 移至 \(A_{n-1}\) 左边形成的局面中存在先手必败状态,那移过去就可以了
那么当 \(A_{n}=A_{n-1}+1\) 时呢?
发现一定不能让移动后形成一个上面所述局面
所以每次操作一定只让 \(A_{n}\) (指移动后的最大数)减少 1
那么判断 \(A_n-(n-1)\) 的奇偶性就可以了
点击查看代码
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define N 300010
#define ll long long
//#define int long long
char buf[1<<21], *p1=buf, *p2=buf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf, 1, 1<<21, stdin)), p1==p2?EOF:*p1++)
inline int read() {
int ans=0, f=1; char c=getchar();
while (!isdigit(c)) {if (c=='-') f=-f; c=getchar();}
while (isdigit(c)) {ans=(ans<<3)+(ans<<1)+(c^48); c=getchar();}
return ans*f;
}
int n;
int a[N];
signed main()
{
n=read();
for (int i=1; i<=n; ++i) a[i]=read();
if (a[n]>a[n-1]+1) puts("Alice");
else if ((a[n]-(n-1))&1) puts("Alice");
else puts("Bob");
return 0;
}
浙公网安备 33010602011771号