D. Let’s Go Hiking
博弈规则读题即可
这边给出解题性质 首先如果有最长路 统一默认起点在左边的话 肯定不会有大于
1
1
1条的不同起点的最长路 否则后手选其他最长路即可
那么我们只要判断是否最长路满足左边与右边相等(如果不相等 后手只要从唯一的奇数里倒数第二个点出发 强行把这条路构造成偶数 后手就赢了) 并且是奇数(奇数保证先手赢)
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<string>
#include<algorithm>
using namespace std;
#define ll long long
#define dbg(x) cout << #x << " = " << (x) << endl;
#define dbg2(x,y) cout << #x << " = " << (x) << " " << #y << " = " << (y) << endl;
#define dbg3(x,y,z) cout << #x << " = " << (x) << " " << #y << " = " << (y) << " " << #z << " = " << (z) << endl;
const int MAX_N = 100025;
int arr[MAX_N],dp[MAX_N][2];
set<int> st;
int main()
{
int n;
scanf("%d",&n);
for(int i = 1;i<=n;++i)
{
scanf("%d",&arr[i]);
}
for(int i = 1;i<=n;++i)
{
if(i==1) dp[i][0] = 1;
else
{
if(arr[i]>arr[i-1]) dp[i][0] = dp[i-1][0] + 1;
else dp[i][0] = 1;
}
}
for(int i = n;i>=1;--i)
{
if(i==n) dp[i][1] = 1;
else
{
if(arr[i]>arr[i+1]) dp[i][1] = dp[i+1][1] + 1;
else dp[i][1] = 1;
}
}
int maxx = 0;
for(int i = 1;i<=n;++i)
{
maxx = max(maxx,max(dp[i][0],dp[i][1]));
}
for(int i = 1;i<=n;++i)
{
if(dp[i][0]==maxx||dp[i][1]==maxx) st.insert(i);
}
if(st.size()>1)
{
return 0*puts("0");
}
int xb = *st.begin();
if((dp[xb][0]==dp[xb][1])&&((dp[xb][0]%2)==1))
{
return 0*puts("1");
}
return 0*puts("0");
return 0;
}