제출 #602585

#제출 시각아이디문제언어결과실행 시간메모리
602585berrKpart (eJOI21_kpart)C++17
30 / 100
2092 ms784 KiB
#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];
        }
 
 
        knp[0]=0;
 
        count[n]=1;
 
        for(int i=n-1; i>=0; i--)
        {
            count[i]=count[i+1]+1;
 
        }   
 
 
        for(int i=0; i<n; i++)
        {
            if(i>0)
            {
                for(int l=pre[i-1]; l>0; l--)
                {
                    if(knp[l]!=-1)
                    {
                        knp[l+a[i]]=max(knp[l+a[i]], knp[l]);
                    }
                }
            }
            knp[a[i]]=max(knp[a[i]], i+p);
            for(int l=2; l<=i+1; l++)
            {
                int a=pre[i];
                if(i-l>=0) a-=pre[i-l];
                if(a%2==0&&knp[a/2]>=p+i-l+1) count[l]--;
            }

           
 
        }
 
        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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...