Submission #438170

#TimeUsernameProblemLanguageResultExecution timeMemory
438170lulwpopBootfall (IZhO17_bootfall)C++14
28 / 100
51 ms540 KiB
#include <bits/stdc++.h> #define all(X) X.begin(), X.end() #define sz(x) (int)x.size() #define fr first #define sc second #define endl '\n' using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair <int, int> pii; typedef pair <ll, ll> pll; const int maxn = 25001; const int maxa = 1e6; const int inf = 2e9; const ll INF = 1e18; const ll mod = 1e9 + 7; const int block = 350; int main () { ios_base::sync_with_stdio(0); cin.tie(); /*#ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif*/ int n; cin >> n; vector <int> a (n); int mx = 0; for (int i = 0; i < n; i++) { cin >> a[i]; mx = max(mx, a[i]); } bitset <maxn> st; int sum = 0; st[0] = 1; for (int i = 0; i < n; i++) { st |= (st << a[i]); sum += a[i]; } if (sum % 2 == 1 || !st[sum >> 1]) { cout << 0; return 0; } vector <int> used (maxn); for (int i = 0; i < n; i++) { bitset <maxn> dp; dp[0] = 1; int cur_sum = 0; for (int j = 0; j < n; j++) { if (i != j) { dp |= (dp << a[j]); cur_sum += a[j]; } } for (int ins = 1; ins < maxn; ins++) { if ((cur_sum + ins) % 2 == 0 && dp[(cur_sum + ins) >> 1]) { used[ins]++; } } } vector <int> ans; for (int i = 0; i < maxn; i++) { if (used[i] == n) { ans.push_back(i); } } cout << sz(ans) << endl; for (auto i : ans) { cout << i << " "; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...