省选考这种题...

显然只要确定前两个就能确定全部...

(我才不会告诉你我交了好多遍才过...)

 

 1 #include<cstdio>
 2 #include<queue>
 3 #include<iostream>
 4 #include<cstring>
 5 using namespace std;
 6 inline int read(){
 7     int ans=0,f=1;char chr=getchar();
 8     while(!isdigit(chr)){if(chr=='-') f=-1;chr=getchar();}
 9     while(isdigit(chr)){ans=(ans<<3)+(ans<<1)+chr-48;chr=getchar();}
10     return ans*f;
11 }int n,m,a[10005],f[10005],ans,maxn;
12 inline int check(){
13     for(int i=2;i<=n;i++){
14         f[i+1]=a[i]-f[i]-f[i-1];
15         if(f[i+1]<0) return 0;
16     }if(f[n+1]>0) return 0;
17     return 1;
18 }int main(){
19     n=read();
20     for(int i=1;i<=n;i++) a[i]=read(),maxn=max(maxn,a[i]);
21     if(n<maxn||a[n]==3||a[1]==3) {cout<<0;return 0;}
22     if(a[1]==0) ans+=check();
23     else if(a[1]==1) f[1]=1,ans+=check(),f[1]=0,f[2]=1,ans+=check();
24     else if(a[1]==2) f[1]=f[2]=1,ans+=check();
25     cout<<ans<<endl;
26     return 0;
27 }