比赛 |
2025暑期集训第2场 |
评测结果 |
AAAAAATTATTTATAAAATA |
题目名称 |
等差子序列 |
最终得分 |
65 |
用户昵称 |
淮淮清子 |
运行时间 |
2.097 s |
代码语言 |
C++ |
内存使用 |
3.75 MiB |
提交时间 |
2025-06-29 17:28:26 |
显示代码纯文本
#include<iostream>
#include<bitset>
using namespace std;
const int MAXN = 1e4 * 3 + 1;
const int dxy = 1e4 + 1;
bitset<MAXN> f1, f2;
int T, n;
bool flag = false;
/*
4
3
1 3 2
3
3 2 1
5
2 1 3 4 5
5
4 2 3 1 5
x << 1
f2 << (x * 2)
>> dxy
*/
int main(){
freopen("sequence.in","r",stdin);
freopen("sequence.out","w",stdout);
cin.tie(0) -> ios::sync_with_stdio(0);
cin >> T;
while(T --){
cin >> n;
f1.reset(); f2.reset(); flag = false;
for (int i = 1, x;i <= n;i ++){
cin >> x;
if(f1[x]) flag = true;
f1 = (f1 | ((f2 << (x << 1)) >> dxy));
f2[dxy - x] = 1;
}
cout << (flag ? "Y\n" : "N\n");
}
return 0;
}