이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2")
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <cstring>
#define endl '\n'
using namespace std;
typedef long long ll;
bitset<1000007>bs;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll t;
cin >> t;
while(t--){
ll n;
cin >> n;
vector<ll>a(n);
for(int i = 0; i < n; i++)
cin >> a[i];
vector<vector<ll>>can(n, vector<ll>(n + 1));
for(int i = 0; i < n; i++){
bs = 0;
ll sum = 0;
bs[a[i]] = 1;
for(int j = i; j < n; j++){
sum += a[j];
bs |= (bs << a[j]);
can[i][j - i + 1] = (sum % 2 == 0 ? bs[sum / 2] : 0);
}
}
vector<ll>ans;
for(int j = 1; j <= n; j++){
bool ok = false;
for(int i = 0; i + j - 1 < n; i++){
if(!can[i][j])
ok = true;
}
if(!ok)
ans.push_back(j);
}
cout << ans.size() << ' ';
for(auto i: ans)
cout << i << ' ';
cout << endl;
}
return 0;
}
/*
1
9
3 2 4 5 1 2 6 7 1
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |