Submission #566206

#TimeUsernameProblemLanguageResultExecution timeMemory
566206RealSnakeBootfall (IZhO17_bootfall)C++14
6 / 100
1090 ms324 KiB
#include "bits/stdc++.h" using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; #define ll long long #define mod 1000000007 ofstream fout(".out"); ifstream fin(".in"); signed main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; int arr[n + 1]; int sum = 0; for(int i = 0; i < n; i++) { cin >> arr[i]; sum += arr[i]; } if(sum % 2) { cout << 0; return 0; } vector<int> ans; for(int i = 1; i <= 2400; i++) { arr[n] = i; bool b = 1; for(int j = 0; j <= n; j++) { if(i > sum || arr[n] % 2 != arr[j] % 2) { b = 0; break; } sum += arr[n]; sum -= arr[j]; swap(arr[j], arr[n]); int x; for(int o = 0; o < (1 << n); o++) { x = 0; for(int k = 0; k < n; k++) { if(o & (1 << k)) x += arr[k]; } if(x == sum / 2) break; } if(x != sum / 2) b = 0; sum += arr[n]; sum -= arr[j]; swap(arr[j], arr[n]); if(!b) break; } if(b) ans.push_back(i); } cout << ans.size() << "\n"; for(int i : ans) cout << i << " "; return 0; }

Compilation message (stderr)

bootfall.cpp: In function 'int main()':
bootfall.cpp:55:13: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   55 |             if(x != sum / 2)
      |             ^~
#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...