#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 >= 200000000) cout << "hai code";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
856 KB |
Output is correct |
2 |
Correct |
7 ms |
864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
860 KB |
Output is correct |
2 |
Correct |
71 ms |
860 KB |
Output is correct |
3 |
Correct |
81 ms |
856 KB |
Output is correct |
4 |
Incorrect |
146 ms |
1112 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |