# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
634992 |
2022-08-25T10:02:32 Z |
giorgikob |
Kpart (eJOI21_kpart) |
C++14 |
|
1464 ms |
197368 KB |
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define count1(x) __builtin_popcount(x)
#define endl '\n'
using namespace std;
const int N = 1e3+1, mod = 1e6, M = 5e4;
vector<int>pre(N+1, 0);
vector<vector<int>> ind(N+1, vector<int>(M+1, 0));
inline void test_case(){
int n;
cin >> n;
for(int i = 1; i <= n; i++){
int x;
cin >> x;
pre[i] = pre[i-1] + x;
for(int sum = 0; sum <= M; sum++){
ind[i][sum] = ind[i-1][sum];
if(sum == x){
ind[i][sum] = i;
} else if(sum > x){
ind[i][sum] = max(ind[i][sum], ind[i-1][sum-x]);
}
}
}
vector<int> ans;
for(int k = 1; k <= n; k++){
bool ok = true;
for(int l = 1; l+k-1 <= n; l++){
int r = l+k-1;
int sum = pre[r] - pre[l-1];
if(sum % 2 != 0 || ind[r][sum/2] < l){
ok = false;
break;
}
}
if(ok){
ans.pb(k);
}
}
cout << ans.size() << " ";
for(auto x : ans){
cout << x << " ";
}
cout << endl;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int T = 1;
cin >> T;
while(T--){
test_case();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
109 ms |
197196 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
159 ms |
197256 KB |
Output is correct |
2 |
Correct |
240 ms |
197196 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
379 ms |
197192 KB |
Output is correct |
2 |
Correct |
611 ms |
197196 KB |
Output is correct |
3 |
Correct |
622 ms |
197288 KB |
Output is correct |
4 |
Correct |
848 ms |
197284 KB |
Output is correct |
5 |
Correct |
1273 ms |
197300 KB |
Output is correct |
6 |
Correct |
1464 ms |
197368 KB |
Output is correct |
7 |
Correct |
1394 ms |
197336 KB |
Output is correct |