#include <bits/stdc++.h>#defineREP (I,A,B) for (int i=a;i<=b;i++)#defineMS0 (a) memset (A,0,sizeof (a))using namespaceStd;typedefLong Longll;Const intmaxn=200100;Const intinf=1<< in;intN,A[MAXN];intL[maxn],r[maxn];map<int,int>Pos;BOOLJudgeintLintR) { if(L>=R)return 1; //cout<<l<< "" <<r<<endl; intLi=l,ri=R; intnex=0; inttag=1; while(li<=RI) { if(tag) {if(l[li]<l&&r[li]>R) {NEX=li; Break; } Li++; } Else{ if(l[ri]<l&&r[ri]>R) {NEX=ri; Break; } ri--; } tag^=1; } if(nex==0)return 0; returnJudge (l,nex-1) &&judge (nex+1, R);}intMain () {Freopen ("In.txt","R", stdin); intT;cin>>u; while(t--) {scanf ("%d",&N); REP (i,1, N) scanf ("%d",&A[i]); Pos.clear (); REP (i,1, N) { if(Pos[a[i]]) l[i]=Pos[a[i]]; Elsel[i]=0; Pos[a[i]]=i; } pos.clear (); for(inti=n;i>=1; i--){ if(Pos[a[i]]) r[i]=Pos[a[i]]; Elser[i]=n+1; Pos[a[i]]=i; } puts (judge (1, N)?"non-boring":"Boring"); } return 0;}/** Add a discretization on the T, fuck ... Anyway, this problem can be optimized ... But this should be a very common thought in the division: the Halfway encounter law. */View Code
UVA 1608 non-boring Sequences