理论上讲这个题是不能暴力的,但是题目太水,下面这份暴力代码裸跑800ms,吸氧80ms
#include<cstdio> #include<string> #include<cstring> #include<iostream> #include<algorithm> #define RE register using namespace std; const int M=5e4+10; int n; int a[M],fr[M],ba[M]; bool check; inline int Read(){ char ch=getchar(); int x=0; while(ch<'0'||ch>'9') ch=getchar(); while(ch>='0'&&ch<='9'){ x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); } return x; } int main(){ RE int T=Read(); while(T--){ memset(fr,0,sizeof(fr)); memset(ba,1,sizeof(ba)); n=Read(); for(RE int i=1;i<=n;i++) a[i]=Read(); check=false; fr[a[1]]=1,ba[a[1]]=0; for(RE int i=2;i<n;i++){ ba[a[i]]=0; for(RE int j=1;j<=min(a[i]-1,n-a[i]);j++) if(fr[a[i]-j]!=fr[a[i]+j]){ check=true; break; } fr[a[i]]=1; } if(check) puts("Y"); else puts("N"); } return 0; }