Submission #602598

#TimeUsernameProblemLanguageResultExecution timeMemory
602598dozerKpart (eJOI21_kpart)C++14
10 / 100
2078 ms241012 KiB
#include <bits/stdc++.h> using namespace std; #define fastio() cin.tie(0), ios_base::sync_with_stdio(0) #define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout) #define pb push_back #define pii pair<int, int> #define endl "\n" #define sp " " #define st first #define nd second #define N 200 #define modulo 1000000007 set<int> dp[N][N]; int arr[N], pre[N]; int main() { fastio(); int t; cin>>t; while(t--) { int n; cin>>n; for (int i = 1; i <= n; i++) { cin>>arr[i]; pre[i] = pre[i - 1] + arr[i]; } for (int i = 1; i <= n; i++) { for (int j = i; j <= n; j++) dp[i][j].clear(); } for (int i = 1; i <= n; i++) dp[i][i].insert(arr[i]); for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { for (auto k : dp[i][j - 1]) dp[i][j].insert(k), dp[i][j].insert(k + arr[j]); dp[i][j].insert(arr[j]); } } vector<int> ans; for (int i = 1; i <= n; i++) { int flag = 1; for (int j = 1; j <= n - i + 1; j++) { if ((pre[j + i - 1] - pre[j - 1]) % 2 == 1) flag = 0; if (dp[j][j + i - 1].count((pre[j + i - 1] - pre[j - 1]) / 2) == 0) flag = 0; } if (flag == 1) ans.pb(i); } cout<<ans.size()<<sp; for (auto i : ans) cout<<i<<sp; cout<<endl; } cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...