# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
632461 |
2022-08-20T05:40:21 Z |
pragmatist |
Kpart (eJOI21_kpart) |
C++17 |
|
2000 ms |
340 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)1e5 + 7;
int n, a[N];
bitset<M> dp;
void solve() {
cin >> n;
for(int i = 1; i <= n; ++i) cin >> a[i];
vector<int> ans;
for(int k = 2; k <= n; ++k) {
bool ok = 1;
for(int i = 1; i <= n - k + 1; ++i) {
dp.reset();
dp[0] = 1;
int sum = 0;
for(int j = i; j <= i + k - 1; ++j) {
sum += a[j];
dp |= dp << a[j];
}
if(sum & 1) {
ok = 0;
break;
}
if(!dp[sum / 2]) {
ok = 0;
break;
}
}
if(ok) ans.pb(k);
}
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 |
Correct |
50 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
896 ms |
340 KB |
Output is correct |
2 |
Execution timed out |
2086 ms |
340 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2092 ms |
340 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |