# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
537466 |
2022-03-15T06:32:16 Z |
joelau |
Kpart (eJOI21_kpart) |
C++14 |
|
2000 ms |
328748 KB |
#include <bits/stdc++.h>
using namespace std;
int T,N,A[1005], sum[1005];
bitset<1005> bs;
unordered_map<int,int> mp;
int dp (int n, int sum) {
if (n == 0) return 0;
if (sum == 0 || sum == A[n]) return n;
if (mp.find(n*1000000+sum) != mp.end()) return mp[n*1000000+sum];
return mp[n*1000000+sum] = max(dp(n-1,sum),dp(n-1,sum-A[n]));
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
cin >> T;
while (T--) {
cin >> N;
A[0] = 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;
mp.clear();
for (int i = 1; i <= N; ++i) for (int j = 1; j <= i; ++j) {
int total = sum[i] - sum[j-1];
if (total % 2 == 1 || dp(i,total/2) < j) bs[i-j+1] = 0;
}
cout << bs.count();
for (int i = 1; i <= N; ++i) if (bs[i]) cout << ' ' << i;
cout << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
68 ms |
2988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
960 ms |
19952 KB |
Output is correct |
2 |
Execution timed out |
2088 ms |
79884 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2094 ms |
328748 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |