problem
solution
codes
#include int n, a[(int)1e5+10];int readint(){ int op=1,x=0; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-')op=-1; ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();} return op*x;}bool check(int dir){ int cnt = 0; for(int i = 2; i <= n; i++, dir=!dir){ //到下一个数判断,方向需要改变 if(a[i]==a[i-1])continue; //值相同毫无存在感 if((a[i] = 2)return false; else i++,dir=!dir; //如果还没有炸,那么要跳过这个值再比较 } return true;}int main(){ while(scanf("%d",&n)==1){ for(int i = 1; i <= n; i++)a[i]=readint(); printf("%s\n",n<=3||check(0)||check(1)?"Yes":"No"); } return 0;}