# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
889573 |
2023-12-20T03:14:28 Z |
8pete8 |
Kpart (eJOI21_kpart) |
C++17 |
|
1873 ms |
1496 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]=i;
}
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 |
Correct |
40 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
118 ms |
1112 KB |
Output is correct |
2 |
Correct |
240 ms |
1244 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
447 ms |
1332 KB |
Output is correct |
2 |
Correct |
766 ms |
1492 KB |
Output is correct |
3 |
Correct |
777 ms |
1332 KB |
Output is correct |
4 |
Correct |
1052 ms |
1496 KB |
Output is correct |
5 |
Correct |
1480 ms |
1288 KB |
Output is correct |
6 |
Correct |
1873 ms |
1328 KB |
Output is correct |
7 |
Correct |
1729 ms |
1116 KB |
Output is correct |