Submission #566243

#TimeUsernameProblemLanguageResultExecution timeMemory
566243RifalBootfall (IZhO17_bootfall)C++14
6 / 100
1090 ms340 KiB
#include <bits/stdc++.h> #include <fstream> #define endl '\n' #define mod 32768 #define INF 100000000000000 //#define ll long long //#define cin fin //#define cout fout using namespace std; //ofstream fout("convention.out"); //ifstream fin("convention.in"); int main() { ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); int n; cin >> n; int arr[n]; int cnt[5000] = {}; set<int> sul; bool check = false; for(int i = 0; i < n; i++) { cin >> arr[i]; } for(int j = 1; j < (1<<(n)); j++) { long long sum1 = 0, sum2 = 0; for(int q = 0; q < n; q++) { if((j&(1<<q)) > 0) { sum1 += arr[q]; } else { sum2 += arr[q]; } } if(sum1 == sum2) { check = true; } } if(!check) { cout << 0 << endl; return 0; } for(int i = 0; i < n; i++) { vector<int> v, ans; bool ccc[5000] = {}; for(int j = 0; j < n; j++) { if(j == i) { continue; } v.push_back(arr[j]); } for(int j = 1; j < (1<<(n-1)); j++) { long long sum1 = 0, sum2 = 0; for(int q = 0; q < n-1; q++) { if((j&(1<<q)) > 0) { sum1 += v[q]; } else { sum2 += v[q]; } } if(ccc[abs(sum1-sum2)] == 0 && abs(sum1-sum2) != 0) { ccc[abs(sum1-sum2)] = 1; ans.push_back(abs(sum1-sum2)); } } for(int j = 0; j < ans.size(); j++) { cnt[ans[j]]++; if(cnt[ans[j]] >= n) sul.insert(ans[j]); } } cout << sul.size() << endl; for(auto i : sul) { cout << i << ' '; } return 0; }

Compilation message (stderr)

bootfall.cpp: In function 'int main()':
bootfall.cpp:83:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |         for(int j = 0; j < ans.size(); j++)
      |                        ~~^~~~~~~~~~~~
#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...