This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define fi first
#define se second
#define sz(v) (int)(v).size()
using namespace std;
const int MXn = 100005;
int n, a[1003], prf[1003];
int dp[MXn];
bool ok[1003];
long long tot = 0;
void solve(void) {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
prf[i] = prf[i - 1] + a[i];
}
memset(dp, -1, sizeof dp);
memset(ok, true, sizeof ok);
int cur = 0;
for (int i = 1; i <= n; i++) {
tot += cur;
for (int s = cur; s > 0; s--) {
dp[s + a[i]] = max(dp[s + a[i]], dp[s]);
}
dp[a[i]] = i;
cur += a[i];
for (int j = 1; j <= i; j++) {
if ((prf[i] - prf[j - 1]) % 2 || dp[(prf[i] - prf[j - 1]) / 2] < j) {
ok[i - j + 1] = false;
}
}
}
vector<int> K;
for (int len = 1; len <= n; len++) if (ok[len]) {
K.emplace_back(len);
}
cout << sz(K) << ' ';
for (int len: K) cout << len << ' ';
cout << '\n';
}
signed main(void) {
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int T; cin >> T; while (T--) solve();
if (tot >= 500000000) cout << "hai code";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |