# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
549166 |
2022-04-15T10:39:01 Z |
spike1236 |
Kpart (eJOI21_kpart) |
C++14 |
|
61 ms |
11380 KB |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define ld long double
#define all(_v) _v.begin(), _v.end()
#define sz(_v) (int)_v.size()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define veci vector <int>
#define vecll vector <ll>
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;
int a[1010];
int dp[1002][50002];
int pref[1002];
int n;
void solve() {
cin >> n;
int sum = 0;
for(int i = 1; i <= n; ++i) {
cin >> a[i];
sum += a[i];
pref[i] = pref[i - 1] + a[i];
}
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= min(pref[i], sum / 2); ++j) {
dp[i][j] = dp[i - 1][j];
if(j == a[i]) dp[i][j] = i;
if(j > a[i]) dp[i][j] = max(dp[i][j], dp[i - 1][j - a[i]]);
}
}
veci ans;
for(int len = 2; len <= n; ++len) {
bool can = 1;
///cout << len << ":\n";
for(int l = 1; l + len - 1 <= n; ++l) {
int r = l + len - 1;
int s = pref[r] - pref[l - 1];
if(s & 1) {
can = 0;
break;
}
///cout << '\t' << dp[r][s / 2] << ' ' << s << ' ' << l << ' ' << r << '\n';
if(dp[r][s / 2] < l) {
can = 0;
break;
}
}
if(can) ans.pb(len);
}
cout << sz(ans) << ' '; for(auto i : ans) cout << i << ' ';
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int CNT_TESTS = 1;
cin >> CNT_TESTS;
for(int NUMCASE = 1; NUMCASE <= CNT_TESTS; ++NUMCASE) {
solve();
if(NUMCASE != CNT_TESTS) cout << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
1364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
61 ms |
11380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |