Submission #889572

# Submission time Handle Problem Language Result Execution time Memory
889572 2023-12-20T03:12:14 Z 8pete8 Kpart (eJOI21_kpart) C++17
0 / 100
441 ms 1228 KB
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include <cassert>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric> //gcd(a,b)
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-loops")
using namespace std;
#define int long long
const int mod=998244353,mxn=500+5,lg=30,inf=1e18,minf=-1e18,Mxn=100000;
void solve(){
    int n;cin>>n;
    vector<int>dp(Mxn+10,-1);
    vector<int>ans(n+1,1);
    vector<int>v(n+1);
    for(int i=1;i<=n;i++)cin>>v[i];
    int sum=0;
    for(int i=1;i<=n;i++){
        sum+=v[i];
        int sub=0;
        for(int j=Mxn;j>=0;j--){
            if(j-v[i]>=0&&dp[j-v[i]]!=-1)dp[j]=max(dp[j],dp[j-v[i]]);
            else if(j-v[i]==0)dp[j]=j;
        }
        sub=sum;
        for(int j=1;j<i;j++){
            if(sub%2==0&&dp[sub/2]>=j)ans[i-j+1]&=true;
            else ans[i-j+1]&=false;
            sub-=v[j];
        }
    }
    int cnt=0;
    for(int i=2;i<=n;i++)if(ans[i])cnt++;
    cout<<cnt<<' ';
    for(int i=2;i<=n;i++)if(ans[i])cout<<i<<" ";
    cout<<'\n';
}
int32_t main(){
    fastio
    int t;cin>>t;
    while(t--)solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 1112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 117 ms 1228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 441 ms 1112 KB Output isn't correct
2 Halted 0 ms 0 KB -