# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1109454 |
2024-11-06T18:18:34 Z |
Irate |
Kpart (eJOI21_kpart) |
C++17 |
|
2000 ms |
1104 KB |
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
cin >> t;
while(t--){
int n;
cin >> n;
vector<int>v(n), res;
vector<vector<int>>good(n, vector<int>(n));
for(int i = 0;i < n;++i){
cin >> v[i];
}
bitset<100005>dp;
for(int i = 0;i < n;++i){
int sum = 0;
dp[0] = 1;
for(int j = i;j < n;++j){
dp |= (dp << v[j]);
sum += v[j];
good[i][j] = (sum % 2 == 0 && dp[sum / 2]);
}
dp.reset();
}
for(int l = 1;l <= n;++l){
bool flag = 1;
for(int i = 0;i + l - 1 < n;++i){
flag = (flag && good[i][i + l - 1]);
}
if(flag)res.push_back(l);
}
cout << (int)res.size() << " ";
for(int i : res){
cout << i << " ";
}
cout << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
336 KB |
Output is correct |
2 |
Correct |
251 ms |
548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1101 ms |
768 KB |
Output is correct |
2 |
Execution timed out |
2061 ms |
1104 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |