Submission #754440

#TimeUsernameProblemLanguageResultExecution timeMemory
754440OlympiaBootfall (IZhO17_bootfall)C++17
13 / 100
1067 ms340 KiB
#include <vector> #include <iostream> #include <cassert> #include <random> #include <cmath> #include <map> #include <algorithm>; #include <bitset> #include <set> #include <stack> using namespace std; bool okay (vector<int> &v, int ind) { int sum = 0; for (int i = 0; i < v.size(); i++) { if (i != ind) { sum += v[i]; } } if (sum % 2 == 1) { return false; } bitset<5000> bs; bs[0] = true; for (int i = 0; i < v.size(); i++) { if (i != ind) { bs |= (bs << v[i]); } } return bs[sum/2]; } vector<int> remove (vector<int> v, int ind) { vector<int> a; for (int i = 0; i < v.size(); i++) { if (i != ind) { a.push_back(v[i]); } } return a; } int main () { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } random_shuffle(v.begin(), v.end()); vector<int> ans; for (int i = 0; i <= 5000; i++) { v.push_back(i); bool fine = true; for (int j = 0; j < v.size(); j++) { if (!okay(v, j)) { fine = false; break; } } if (fine) { ans.push_back(i); } v.pop_back(); } cout << ans.size() << endl; for (int i: ans) { cout << i << ' '; } cout << endl; }

Compilation message (stderr)

bootfall.cpp:7:21: warning: extra tokens at end of #include directive
    7 | #include <algorithm>;
      |                     ^
bootfall.cpp: In function 'bool okay(std::vector<int>&, int)':
bootfall.cpp:14:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for (int i = 0; i < v.size(); i++) {
      |                  ~~^~~~~~~~~~
bootfall.cpp:24:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  for (int i = 0; i < v.size(); i++) {
      |                  ~~^~~~~~~~~~
bootfall.cpp: In function 'std::vector<int> remove(std::vector<int>, int)':
bootfall.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  for (int i = 0; i < v.size(); i++) {
      |                  ~~^~~~~~~~~~
bootfall.cpp: In function 'int main()':
bootfall.cpp:54:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |      for (int j = 0; j < v.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...