Submission #635761

#TimeUsernameProblemLanguageResultExecution timeMemory
635761deme_bzKpart (eJOI21_kpart)C++14
100 / 100
1545 ms197316 KiB
#pragma GCC diagnostic warning "-std=c++11" #include <bits/stdc++.h> #define ll long long #define pb push_back #define all(x) (x).begin(), (x).end() #define ff first #define ss second #define eb emplace_back #define sz(x) (int)x.size() using namespace std; const int N=1e3+1,MAX=5e4; vector <int> pre(N+1,0); vector < vector<int> > ind(N+1,vector <int> (MAX+1, 0)); void test_case(){ int n; cin >> n; for(int i=1;i<=n;i++){ int a; cin >> a; pre[i]=pre[i-1]+a; for(int j=0;j<=MAX;j++){ ind[i][j]=ind[i-1][j]; if(j==a){ ind[i][j]=i; } else if(j>a){ ind[i][j]=max(ind[i][j],ind[i-1][j-a]); } } } vector <int> ans; for(int k=1;k<=n;k++){ bool B=true; for(int l=1;l<=n-k+1;l++){ int r=l+k-1; int sum=pre[r]-pre[l-1]; if(sum%2!=0 || ind[r][sum/2]<l){ B=false; break; } } if(B){ ans.pb(k); } } //cout << endl; cout << ans.size() << " "; for(auto to : ans){ cout << to << " "; } cout << endl; } int main(){ int T = 1; cin >> T; while(T--){ test_case(); } }

Compilation message (stderr)

Main.cpp:1:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
    1 | #pragma GCC diagnostic warning "-std=c++11"
      |                                ^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...