Submission #319210

#TimeUsernameProblemLanguageResultExecution timeMemory
319210BeanZBootfall (IZhO17_bootfall)C++14
44 / 100
1093 ms1512 KiB
// I_Love_LPL #include <bits/stdc++.h> using namespace std; #define task "A" #define ll long long #define endl '\n' const int N = 505; const int mod = 1e9 + 7; const int lim = 500 * 500; bitset<lim> bit; ll a[N]; bool flag[N * N], tmp[N * N]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } ll n; cin >> n; ll sum = 0; for (int i = 1; i <= n; i++) cin >> a[i], sum += a[i]; for (int i = 1; i <= lim; i++) flag[i] = 1; bit[0] = 1; for (int i = 1; i <= n; i++){ bit |= (bit << a[i]); } if (bit[sum / 2] == 0) return cout << 0, 0; for (int i = 1; i <= n; i++){ bit.reset(); bit[0] = 1; for (int j = 1; j <= n; j++){ if (i == j) continue; bit |= (bit << a[j]); } //cout << bit << endl; memset(tmp, 0, sizeof(tmp)); for (int j = 0; j <= lim; j++){ if (bit[j] && ((sum - j - a[i] - j) > 0)){ tmp[sum - j - a[i] - j] = 1; //cout << sum - j - a[i] << " "; } } //cout << endl; for (int j = 1; j <= lim; j++){ flag[j] &= tmp[j]; } } vector<ll> ans; for (int i = 1; i <= lim; i++){ if (flag[i]) ans.push_back(i); } cout << ans.size() << endl; for (auto j : ans) cout << j << " "; } /* 4 1 3 1 5 6 3 5 7 11 9 13 3 2 2 2 */

Compilation message (stderr)

bootfall.cpp: In function 'int main()':
bootfall.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   17 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bootfall.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   18 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...