# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
637747 |
2022-09-03T06:21:52 Z |
VitaliyFS |
Kpart (eJOI21_kpart) |
C++17 |
|
1338 ms |
153136 KB |
#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef long double ld;
const ll INF = 1000000000000000007, DIM = 100007, DIM2 = 107, MAXN = 100007, MOD = 1000000007;
ll tt, mid, res,f, y, type, a[DIM], dp[DIM2][DIM], pref[DIM], ptr, root, cnt, sum, pos, h, p, sx,sy, id, testcase, curans, nn, split, n, m, x, k1, k2, changecnt,k,l,r,v,u, l1,r1,l2,r2;
bool flag, flag2;
char c;
vector<ll> ans;
void solve() {
ans.clear();
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];pref[i]=pref[i-1]+a[i];
}
for(int i=2;i<=n;i++){
flag=1;
for(int ii=1;ii<=n-i+1;ii++) {
if((pref[ii+i-1]-pref[ii-1])%2){flag=0;break;}
sum=0;
for(int j=0;j<=100000;j++)dp[ii-1][j]=0;
dp[ii-1][0]=1;
for(int j=ii;j<=ii+i-1;j++) {
sum+=a[j];
for(int k=0;k<=sum;k++) {
dp[j][k]=0;
dp[j][k]=dp[j-1][k];
if(k>=a[j]) dp[j][k]=max(dp[j][k],dp[j-1][k-a[j]]);
}
}
if(!dp[ii+i-1][sum/2]){flag=0;break;}
}
if(flag)ans.push_back(i);
}
cout<<ans.size()<<' ';
for(auto u : ans)cout<<u<<" ";
cout<<'\n';
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
tt=1;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
cin>>tt;
while(tt--) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
70 ms |
18568 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1338 ms |
49224 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
93 ms |
153136 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |