Alice and Bob are playing a game. They are given an array AA of length NN. The array consists of integers. They are building a sequence together. In the beginning, the sequence is empty. In one turn a player can remove a number from the left or right side of the array and append it to the sequence. The rule is that the sequence they are building must be strictly increasing. The winner is the player that makes the last move. Alice is playing first. Given the starting array, under the assumption that they both play optimally, who wins the game?
Input
The first line contains one integer NN (1≤N≤2∗1051≤N≤2∗105) - the length of the array AA.
The second line contains NN integers A1A1, A2A2,...,ANAN (0≤Ai≤1090≤Ai≤109)
Output
The first and only line of output consists of one string, the name of the winner. If Alice won, print "Alice", otherwise, print "Bob".
题意:有一个个数为n的数组,a和b每次只能选第一个或者最后一个,每次选的数要比前面选过的数都大,第一个可以随便选,a第一个选,问谁最后能赢
结论:从头开始的连续递增序列的长度和从尾开始的连续递增序列的长度只要有一个是奇数的话就是a赢,都是偶数的话就是b赢。
思路:因为我们每次只能选第一个或最后一个,
那么我们就看从第一个开始最长递增序列的长度是多少,长度设为con1,
然后再看从最后一个开始最长递增序列的长度是多少,长度设为con2。
因为a先选,a选过之后留给b的数都是偶数个,那么b选过之后肯定能留给a一个数让a来选,那么a就赢了,否则的话就是b赢
/*
.----------------. .----------------. .----------------. .----------------.
| .--------------. || .--------------. || .--------------. || .--------------. |
| | ________ | || | _________ | || | ____ ____ | || | ____ | |
| | |_ ___ `. | || | |_ ___ | | || ||_ \ / _|| || | .' `. | |
| | | | `. \ | || | | |_ \_| | || | | \/ | | || | / .--. \ | |
| | | | | | | || | | _| _ | || | | |\ /| | | || | | | | | | |
| | _| |___.' / | || | _| |___/ | | || | _| |_\/_| |_ | || | \ `--' / | |
| | |________.' | || | |_________| | || ||_____||_____|| || | `.____.' | |
| | | || | | || | | || | | |
| '--------------' || '--------------' || '--------------' || '--------------' |
'----------------' '----------------' '----------------' '----------------'
*/
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<cmath>
#include<stack>
#define int long long
#define lowbit(x) x&(-x)
#define PI 3.1415926535
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int gcd(int a,int b){
return b>0 ? gcd(b,a%b):a;
}
/*
int dx[8]={-2,-2,-1,1,2,2,-1,1};
int dy[8]={-1,1,2,2,1,-1,-2,-2};
int dx[4]={0,-1,0,1};
int dy[4]={-1,0,1,0};
int dx[8]={-1,1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};
*/
//int e[N],ne[N],h[N],idx,w[N];
/*void add(int a,int b,int c){
e[idx]=b;
w[idx]=c;
ne[idx]=h[a];
h[a]=idx++;
}
*/
const int N=2e5+10;
int n;
int a[N];
//可以用最尽头的数的点权加上走到1的最短路
void sove(){
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
int con1=1,con2=1;
for(int i=2;i<=n;i++){
if(a[i]>a[i-1])con1++;
else break;
}
for(int i=n-1;i>=1;i--){
if(a[i]>a[i+1])con2++;
else break;
}
if(con1&1||con2&1){
cout<<"Alice"<<endl;
}else cout<<"Bob"<<endl;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie() ,cout.tie() ;
int t=1;
// cin>>t;
while(t--){
sove();
}
return 0;
}