Submission #1040268

#TimeUsernameProblemLanguageResultExecution timeMemory
1040268kl0989eKpart (eJOI21_kpart)C++17
30 / 100
2071 ms9748 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define pb push_back #define vi vector<int> #define vl vector<ll> #define pi pair<int, int> #define pl pair<ll,ll> #define all(x) (x).begin(),(x).end() void solve() { int n; cin >> n; vi a(n); int sum=0; for (int i=0; i<n; i++) { cin >> a[i]; sum+=a[i]; } vector<bitset<100001>> sets(n,0); for (int i=0; i<n; i++) { sets[i][50000]=1; sets[i]=(sets[i]<<a[i])|(sets[i]>>a[i]); } vi ans; for (int i=1; i<n; i++) { bool ok=1; for (int j=0; j+i<n; j++) { sets[j]=(sets[j]<<a[j+i])|(sets[j]>>a[j+i]); if (!sets[j][50000]) { ok=0; } } if (ok) { ans.pb(i+1); } } cout << ans.size() << ' '; for (auto a:ans) { cout << a << ' '; } cout << '\n'; } int32_t main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); int t; cin >> t; while (t--) { solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...