# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
790949 |
2023-07-23T09:44:48 Z |
otarius |
Kpart (eJOI21_kpart) |
C++17 |
|
1450 ms |
193500 KB |
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cstring>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define ff first
#define sc second
#define pb push_back
#define ll long long
#define pll pair<ll, ll>
#define pii pair <int, int>
#define ull unsigned long long
// #define int long long
// #define int unsigned long long
const ll inf = 1e9 + 7;
const ll weirdMod = 998244353;
void solve() {
int n;
cin >> n;
int arr[n + 1], pref[n + 1]; pref[0] = 0;
for (int i = 1; i <= n; i++) {
cin >> arr[i]; pref[i] = arr[i] + pref[i - 1];
} int sum = pref[n], dp[n + 1][sum / 2 + 5], cur;
for (int i = 0; i <= n; i++)
for (int j = 0; j <= sum / 2; j++)
dp[i][j] = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= sum / 2; j++) {
dp[i][j] = dp[i - 1][j];
if (j > arr[i]) dp[i][j] = max(dp[i][j], dp[i - 1][j - arr[i]]);
if (j == arr[i]) dp[i][j] = i;
}
} vector<int> good;
for (int len = 2; len <= n; len++) {
bool flg = 1;
for (int i = len; i <= n; i++) {
cur = pref[i] - pref[i - len];
if ((cur & 1) || dp[i][cur / 2] <= i - len) {
flg = 0; break;
}
} if (flg) good.pb(len);
} cout << good.size() << ' ';
for (int v : good) cout << v << ' ';
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
int t = 1;
cin >> t;
while (t--) {
solve();
cout << '\n';
} return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1308 KB |
Output is correct |
2 |
Correct |
16 ms |
3412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
13212 KB |
Output is correct |
2 |
Correct |
210 ms |
29696 KB |
Output is correct |
3 |
Correct |
242 ms |
37852 KB |
Output is correct |
4 |
Correct |
444 ms |
64464 KB |
Output is correct |
5 |
Correct |
1033 ms |
159016 KB |
Output is correct |
6 |
Correct |
1450 ms |
192576 KB |
Output is correct |
7 |
Correct |
1322 ms |
193500 KB |
Output is correct |