Upper hand win condition to be met in at least \ (1 \) Section:
- A first come from the initial position to the left \ (0 \) position, through an even number of sides (including \ (0 \) this edge).
- A first come from the initial position to the right \ (0 \) position, through an even number of sides (including \ (0 \) this edge).
Otherwise losing the upper hand.
#include<stdio.h>
#include<string.h>
using namespace std;
const int maxn = 25;
int a[maxn], n, ans;
int main()
{
scanf("%d", &n);
ans = 0;
for(int i = 1; i <= n; i++){
scanf("%d", &a[i]);
}
for(int i = 1; i <= n; i++){
if(a[i] == 0){
if(i % 2 == 0) ans = 1;
break;
}
}
for(int i = n; i >= 1; i--){
if(a[i] == 0){
if((n + 1 - i) % 2 == 0) ans = 1;
break;
}
}
if(ans == 1) puts("YES");
else printf("NO");
return 0;
}