标签:pre 取石子 ios font == printf class 网上 ++
ORZ
做法跟网上是一样的,自己照着手推一次好了。
#include<cstdio> #include<iostream> #include<cstring> #include<cstdlib> #include<algorithm> #include<cmath> using namespace std; int a[1100],L[1100][1100],R[1100][1100]; int main() { freopen("a.in","r",stdin); freopen("a.out","w",stdout); int T; scanf("%d",&T); while(T--) { int n; scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]),L[i][i]=R[i][i]=1; for(int C=1;C<=n;C++) for(int l=1;l<=n;l++) { int r=l+C-1;if(r>n)break; if(R[l][r-1]==a[r])L[l][r]=0; else if(L[l][r-1]> a[r]&&R[l][r-1]>a[r])L[l][r]=a[r]; else if(L[l][r-1]> a[r]&&R[l][r-1]<a[r])L[l][r]=a[r]-1; else if(L[l][r-1]<=a[r]&&R[l][r-1]>a[r])L[l][r]=a[r]+1; else if(L[l][r-1]< a[r]&&R[l][r-1]<a[r])L[l][r]=a[r]; if(L[l+1][r]==a[l])R[l][r]=0; else if(R[l+1][r]> a[l]&&R[l+1][r]>a[l])R[l][r]=a[l]; else if(R[l+1][r]> a[l]&&R[l+1][r]<a[l])R[l][r]=a[l]-1; else if(R[l+1][r]<=a[l]&&R[l+1][r]>a[l])R[l][r]=a[l]+1; else if(R[l+1][r]< a[l]&&R[l+1][r]<a[l])R[l][r]=a[l]; } printf("%d\n",(L[2][n]==a[1])?0:1); } return 0; }
标签:pre 取石子 ios font == printf class 网上 ++
原文地址:https://www.cnblogs.com/AKCqhzdy/p/10184461.html