Submission #602764

# Submission time Handle Problem Language Result Execution time Memory
602764 2022-07-23T11:05:48 Z berr Kpart (eJOI21_kpart) C++17
0 / 100
327 ms 395856 KB
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> check(1005, vector<int>(100005, 0));
 
int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t; cin>>t; 
    int p=2;
    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<int> knp(1e5, -1);


        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+p;
                }
            }
        }

        count[n]=1;
 
        for(int i=n-1; i>=0; i--)
        {
            count[i]=count[i+1]+1;
 
        }   

       
        for(int i=0; i<n; i++)
        {
            for(int l=pre[n-1]/2; l>0; l--)
            {
                if(knp[l]>=0)
                {       
                    knp[l+a[i]]=max(knp[l], knp[l+a[i]]);
                    if(check[i][a[i]+l]>p&&knp[a[i]+l]>=i-check[i][a[i]+l]+1-p)
                    {
                        count[check[i][a[i]+l]-p]--;
                    }
                }
            }

            knp[a[i]]=i;

            if(check[i][a[i]]>p)
            {
                count[check[i][a[i]]-p]--;
            }
        }
 

        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 161 ms 395812 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 166 ms 395856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 327 ms 395856 KB Output isn't correct
2 Halted 0 ms 0 KB -