제출 #630884

#제출 시각아이디문제언어결과실행 시간메모리
630884ZsofiaKeresztelyKpart (eJOI21_kpart)C++14
10 / 100
2109 ms518872 KiB
#include <bits/stdc++.h>
using namespace std;

int main(){
  int t, n, sum, op;
  cin >> t;
  vector<int> a;
  set<int> sums;
  vector<vector<map<int, bool> > > psbl;
  vector<bool> k;
  while (t--){
    cin >> n;
    a.resize(n);
    vector<vector<map<int, bool> > > psbl(n, vector<map<int, bool> >(n));
    k.assign(n+1, true);
    k[0] = false;
    k[1] = false;
    for (int i=0; i<n; i++){
      cin >> a[i];
    }
    for (int i=0; i<n; i++){
      psbl[i][i][0] = true;
      psbl[i][i][a[i]] = true;
      sum = a[i];
      for (int j=i+1; j<n; j++){
        for (auto x : psbl[i][j-1]){
          if (!x.second) continue;
          psbl[i][j][x.first] = true;
          if (x.first + a[j] <= 50000){
            psbl[i][j][x.first + a[j]] = true;
          }
        }
        sum += a[j];
        if (sum % 2 || !psbl[i][j][sum/2]){
          k[j-i+1] = false;
        }
      }
    }
    op = 0;
    for (int x : k){
      if (x){
        op++;
      }
    }
    cout << op << " ";
    for (int i=1; i<n+1; i++){
      if (k[i]){
        cout << i << " ";
      }
    }
    cout << "\n";
  }
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...