# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
602600 |
2022-07-23T09:19:02 Z |
berr |
Kpart (eJOI21_kpart) |
C++17 |
|
487 ms |
27152 KB |
#include <bits/stdc++.h>
using namespace std;
vector<int> knp(100005);
int32_t main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
int t; cin>>t;
int p=0;
while(t--)
{
int n; cin>>n;
vector<int> pre(n), a(n), count(n+1);
for(int i=0; i<n; i++)
{
cin>>a[i];
if(i==0) pre[i]=a[i];
else pre[i]=pre[i-1]+a[i];
}
vector<vector<int>> check(n, vector<int>(pre[n-1]+5, 0));
for(int i=0; i<n; i++)
{
for(int l=2; l<=i+1; l++)
{
int a=pre[i];
if(i-l>=0) a-=pre[i-l];
if(a%2==0)
{
check[i][a/2]=l;
}
}
}
knp[0]=0;
count[n]=1;
for(int i=n-1; i>=0; i--)
{
count[i]=count[i+1]+1;
}
vector<int> q;
vector<int> vis(100005);
for(int i=0; i<n; i++)
{
for(auto l: q)
{
if(check[i][l+a[i]]&&knp[l]>=i+p-check[i][l+a[i]]+1)
{
count[check[i][l+a[i]]]--;
}
}
if(check[i][a[i]]&&knp[a[i]]>=i+p-check[i][a[i]]+1)
{
count[check[i][a[i]]]--;
}
int z=q.size();
for(int l=0; l<z; l++)
{
knp[q[l]+a[i]]=max(knp[q[l]]+a[i], knp[q[l]]);
if(vis[q[l]+a[i]]==0)
{
vis[q[l]+a[i]]=1;
q.push_back(q[l]+a[i]);
}
}
knp[a[i]]=i+p;
if(vis[a[i]]==0)
{
vis[a[i]]=1;
q.push_back(a[i]);
}
}
vector<int> ans;
for(int i=2; i<=n; i++)
{
if(count[i]==0) ans.push_back(i);
}
cout<<ans.size()<<" ";
for(auto i: ans) cout<<i<<" ";
cout<<"\n";
p+=n;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
1568 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
33 ms |
3084 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
487 ms |
27152 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |