# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1221784 | Robert_junior | Kpart (eJOI21_kpart) | C++20 | 2092 ms | 492 KiB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define ins insert
#define pb push_back
#define F first
#define S second
const int N = 1e6+4, M = 5e5 + 7;
const int mod = 1e9 + 7;
int a[N], ok[N];
void solve(){
int n;
cin>>n;
for(int i = 1; i <= n; i++){
cin>>a[i];
ok[i] = 1;
}
for(int i = 1; i <= n; i++){
int sum = 0, mx = 0;
bitset<50001>dp;
dp[0] = 1;
for(int j = i; j <= n; j++){
sum += a[j];
mx = max(mx, a[j]);
if(a[j] <= 50000) dp |= (dp<<a[j]);
if(mx * 2 > sum || sum % 2 == 1 || dp[sum / 2] == 0){
ok[(j - i + 1)] = 0;
}
}
}
vector<int>res;
for(int i = 2; i <= n; i++) if(ok[i]) res.pb(i);
cout<<res.size()<<' ';
for(auto it : res) cout<<it<<' ';
cout<<'\n';
}
main(){
ios_base :: sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin>>t;
for(int i = 1; i <= t; i++){
//cout<<"Case "<<i<<": ";
solve();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |