# 【刷题】BZOJ 4059 [Cerc2012]Non-boring sequences

4
5
1 2 3 4 5
5
1 1 1 1 1
5
1 2 3 2 1
5
1 1 2 1 1

non-boring
boring
non-boring
boring

## Solution

#include<bits/stdc++.h>
#define ui unsigned int
#define ll long long
#define db double
#define ld long double
#define ull unsigned long long
const int MAXN=200000+10;
int T,n,a[MAXN],pre[MAXN],nxt[MAXN];
std::map<int,int> M;
template<typename T> inline void read(T &x)
{
T data=0,w=1;
char ch=0;
while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
if(ch=='-')w=-1,ch=getchar();
while(ch>='0'&&ch<='9')data=((T)data<<3)+((T)data<<1)+(ch^'0'),ch=getchar();
x=data*w;
}
template<typename T> inline void write(T x,char ch='\0')
{
if(x<0)putchar('-'),x=-x;
if(x>9)write(x/10);
putchar(x%10+'0');
if(ch!='\0')putchar(ch);
}
template<typename T> inline void chkmin(T &x,T y){x=(y<x?y:x);}
template<typename T> inline void chkmax(T &x,T y){x=(y>x?y:x);}
template<typename T> inline T min(T x,T y){return x<y?x:y;}
template<typename T> inline T max(T x,T y){return x>y?x:y;}
inline bool solve(int l,int r)
{
if(r<=l)return true;
int p=l,q=r;
for(register int p=l,q=r;p<=q;++p,--q)
if(pre[p]<l&&nxt[p]>r)return solve(l,p-1)&&solve(p+1,r);
else if(p!=q&&pre[q]<l&&nxt[q]>r)return solve(l,q-1)&&solve(q+1,r);
return false;
}
int main()
{
while(T--)
{