# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1107405 | vjudge1 | Kpart (eJOI21_kpart) | C++17 | 2077 ms | 848 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define iosBASE ios::sync_with_stdio(false);cin.tie(0);cout.tie (0);
void Freopen () {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
const ll INF = (ll)1e18 + 7;
const ll mod = (ll)1e9 + 7;
const ll N = 1e5 + 5;
using namespace std;
int n, a[N], cnt[N], ok[N];
void ma1n () {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
cnt[i] = 0;
}
vector <int> ans;
ok[0] = 1;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= 1e5; j++) ok[j] = 0;
int sum = 0;
for (int j = i; j <= n; j++) {
for (int k = 1e5; k >= 0; k--) {
if (ok[k]) ok[k + a[j]] = 1;
}
sum += a[j];
if (sum % 2 == 0 && ok[sum / 2]) {
cnt[j - i + 1]++;
if (cnt[j - i + 1] == n - j + i) {
ans.push_back (j - i + 1);
}
}
}
}
sort (ans.begin (), ans.end ());
cout << ans.size () << " ";
for (auto to : ans) {
cout << to << " ";
}
cout << "\n";
}
int main () {
int t = 1;
cin >> t;
for (int i = 1; i <= t; i++) {
ma1n ();
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |