#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native")
const int N = 200'000, inf = 1'000'000'000;
const i64 infl = 1'000'000'000'000'000'000;
#define ff first
#define ss second
#define pb push_back
#define ins insert
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define NO cout << "NO\n"
#define YES cout << "YES\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int __tc = 1;
int n;
int a[N+5], b[N+5], p[N+5];
void solve() {
vector<int>ans;
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) p[i] = p[i-1] + a[i];
for (int len = 1; len <= n; len++) {
int ok = 1;
for (int l = 1; l + len - 1 <= n; l++) {
int r = l + len - 1;
if ((p[r] - p[l - 1]) & 1) { ok = 0; break; }
vector<int>dp(p[r] - p[l - 1] + 5, 0);
dp[0] = 1;
for (int i = l; i <= r; i++) {
for (int j = p[r] - p[l - 1]; j >= a[i]; j--) {
if (dp[j - a[i]]) dp[j] = 1;
}
}
if (!dp[(p[r] - p[l - 1]) >> 1]) {
ok = 0;
break;
}
}
if (ok) ans.pb(len);
}
cout << sz(ans) << ' ';
for (int x : ans) cout << x << ' ';
cout << '\n';
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
cin >> __tc;
for (int _tc = 1; _tc <= __tc; _tc++) {
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |