Submission #1099934

#TimeUsernameProblemLanguageResultExecution timeMemory
1099934nnqwBootfall (IZhO17_bootfall)C++17
13 / 100
1026 ms604 KiB
#include "bits/stdc++.h" using namespace std; #define all(v) v.begin(), v.end() #define ll long long const int N = 505; int a[N]; int main() { int n; scanf("%d", &n); for(int i = 1; i <= n; ++i) scanf("%d", &a[i]); int sm = accumulate(a + 1, a + n + 1, 0); vector<int> A; for(int x = 0; x <= sm; ++x) { a[n + 1] = x; // Tima's fixed strength bool done = true; for(int ad = 1; ad <= n + 1 && done; ++ad) { vector<int> v; for(int i = 1; i <= n + 1; ++i) { if(i != ad) v.push_back(a[i]); } int total = accumulate(all(v), 0); if (total % 2 != 0) { done = false; // If total is odd, cannot split evenly continue; } int half = total / 2; vector<bool> dp(half + 1, false); dp[0] = true; for(int &to : v) { for(int i = half; i >= to; --i) { dp[i] = dp[i] || dp[i - to]; } } done &= dp[half]; // Check if we can form half } if(done) A.push_back(x); } printf("%d\n", (int)A.size()); for(int i : A) printf("%d ", i); puts(""); return 0; }

Compilation message (stderr)

bootfall.cpp: In function 'int main()':
bootfall.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
bootfall.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
#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...