#include <bits/stdc++.h>
using namespace std;
int T,N,A[1005], sum[1005], dp[2][100005];
bitset<1005> bs;
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
cin >> T;
while (T--) {
cin >> N;
sum[0] = 0;
for (int i = 1; i <= N; ++i) {
cin >> A[i];
sum[i] = sum[i-1] + A[i];
}
bs.reset();
for (int i = 1; i <= N; ++i) bs[i] = 1;
memset(dp[1],-1,sizeof(dp[1]));
dp[1][0] = 0;
for (int i = 1; i <= N; ++i) {
dp[0][0] = dp[0][A[i]] = i;
for (int j = 0; j + A[i] <= sum[i] && j + A[i] <= sum[N]/2; ++j) dp[0][j] = max(dp[0][j],dp[1][j]), dp[0][j+A[i]] = max(dp[0][j+A[i]],dp[1][j]);
for (int j = 1; j <= i; ++j) {
int total = sum[i] - sum[j-1];
if (total % 2 == 1 || dp[0][total/2] < j) bs[i-j+1] = 0;
}
swap(dp[0],dp[1]);
}
cout << bs.count();
for (int i = 1; i <= N; ++i) if (bs[i]) cout << ' ' << i;
cout << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
37 ms |
1112 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
107 ms |
1108 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
430 ms |
1108 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |