# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
632633 |
2022-08-20T13:22:33 Z |
pragmatist |
Kpart (eJOI21_kpart) |
C++17 |
|
1443 ms |
2288 KB |
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz(v) (int)v.size()
#define nl "\n"
using namespace std;
const int N = (int)1e3 + 7;
const int MOD = (int)1e9 + 7;
const int M = (int)5e5 + 7;
int n, a[N], dp[M], lst[M];
bool ok[N];
void solve() {
cin >> n;
for(int i = 1; i <= n; ++i) cin >> a[i];
fill(ok + 1, ok + 1 + n, 1);
fill(lst, lst + M, -1);
lst[0] = 0;
for(int i = 1; i <= n; ++i) {
for(int w = M - a[i] - 1; w >= 0; --w) {
if(lst[w] != -1) lst[w + a[i]] = max(lst[w + a[i]], i);
}
int sum = 0;
for(int j = i; j >= 1; --j) {
sum += a[j];
if(sum & 1) {
ok[i - j + 1] = 0;
} else {
if(lst[sum / 2] < j) ok[i - j + 1] = 0;
}
}
}
vector<int> ans;
for(int i = 1; i <= n; ++i) if(ok[i]) ans.pb(i);
cout << sz(ans) << ' ';
for(auto x : ans) cout << x << ' ';
cout << nl;
}
int main() {
ios_base::sync_with_stdio(NULL);
cin.tie(0);
cout.tie(0);
int test;
cin >> test;
while(test--) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
135 ms |
2260 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
370 ms |
2268 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1443 ms |
2288 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |