Submission #1221784

#TimeUsernameProblemLanguageResultExecution timeMemory
1221784Robert_juniorKpart (eJOI21_kpart)C++20
30 / 100
2092 ms492 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)

Main.cpp:38:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   38 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...