Submission #839658

#TimeUsernameProblemLanguageResultExecution timeMemory
839658alishejhfKpart (eJOI21_kpart)C++17
30 / 100
2082 ms456 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include<bits/stdc++.h> #define ent '\n' #define fi first #define se second #define sz(x) (int)x.size() #define pb push_back #define all(x) x.begin(),x.end() using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; const int N = 1e3 + 10; const int mod = 1e9 + 7; const int inf = (int)(1e9 + 7); const ll INF = (ll)(2e18 + 7); const ld eps = (ld)(1e-12); const int dx[] = { -1,0,1,0,1,1,-1,-1 }, dy[] = { 0,1,0,-1,1,-1,1,-1 }; mt19937 mrand(random_device{}()); int rnd(int x) { return mrand() % x; } int n,a[N],cnt[N]; bitset<50001> dp; void solve(){ cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; cnt[i]=0; } for(int i=1;i<=n;i++){ ll sum=0; dp.reset(); dp[0]=1; for(int j=i;j<=n;j++){ sum+=a[j]; dp|=dp<<a[j]; if(sum&1) continue; if((sum>>1)>5e4){ break; } if(dp[sum>>1]){ ++cnt[j-i+1]; } } } vector<int> ans; for(int i=1;i<=n;i++){ if(cnt[i]==n-i+1){ ans.pb(i); } } cout<<sz(ans)<<' '; for(auto it:ans){ cout<<it<<' '; } cout<<ent; return; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); srand(time(0)); //freopen(".in", "r", stdin); //freopen(".out","w",stdout); int ttt=1; cin>>ttt; for(int i=1;i<=ttt;i++){ //cout<<"NEWCASE"<<ent; solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...