bzoj2124-等差子序列

//to update

#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
using namespace std;
#define rep(i,l,r) for(register int i=(l);i<=(r);++i)
#define repdo(i,l,r) for(register int i=(l);i>=(r);--i)
#define il inline
typedef double db;
typedef long long ll;

//---------------------------------------
const int nsz=10050;
int t,n,line[nsz];
int main(){
	ios::sync_with_stdio(0),cin.tie(0);
	cin>>t;
	rep(cs,1,t){
		bitset<10005> bs1,bs2;
		cin>>n;
		rep(i,1,n)cin>>line[i],bs2[line[i]]=1;
		int res=0;
		rep(i,1,n){
			bs2[line[i]]=0;
			int tmp=10000-2*line[i];
			if(tmp>0){
				if(((bs1>>tmp)&bs2).any()){res=1;break;}
			}
			else{
				if(((bs1<<(-tmp))&bs2).any()){res=1;break;}
			}
			bs1[10000-line[i]]=1;
		}
		cout<<(res?"Y":"N")<<'\n';
	}
	return 0;
}
posted @ 2019-01-10 16:14  Ubospica  阅读(104)  评论(0编辑  收藏  举报