Submission #754283

# Submission time Handle Problem Language Result Execution time Memory
754283 2023-06-07T12:08:37 Z Olympia Bootfall (IZhO17_bootfall) C++17
Compilation error
0 ms 0 KB
#include <vector>
#include <iostream>
#include <cassert>
#include <cmath>
#include <map>
#include <set>
#include <stack>
using namespace std;
bool okay (vector<int> v) {
	int sum = 0;
	for (int i: v) {
		sum += i;
	}
	if (sum % 2 == 1) {
		return false;
	}
	bitset<5000> bs;
	bs[0] = true;
	for (int i: v) {
		bs |= (bs << 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];
    }
    vector<int> ans;
    for (int i = 0; i <= 500; i++) {
    	v.push_back(i);
    	bool fine = true;
    	for (int j = 0; j < v.size(); j++) {
    		if (!okay(remove(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

bootfall.cpp: In function 'bool okay(std::vector<int>)':
bootfall.cpp:17:2: error: 'bitset' was not declared in this scope
   17 |  bitset<5000> bs;
      |  ^~~~~~
bootfall.cpp:8:1: note: 'std::bitset' is defined in header '<bitset>'; did you forget to '#include <bitset>'?
    7 | #include <stack>
  +++ |+#include <bitset>
    8 | using namespace std;
bootfall.cpp:17:15: error: 'bs' was not declared in this scope; did you mean 'abs'?
   17 |  bitset<5000> bs;
      |               ^~
      |               abs
bootfall.cpp: In function 'std::vector<int> remove(std::vector<int>, int)':
bootfall.cpp:26:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |  for (int i = 0; i < v.size(); i++) {
      |                  ~~^~~~~~~~~~
bootfall.cpp: In function 'int main()':
bootfall.cpp:46:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |      for (int j = 0; j < v.size(); j++) {
      |                      ~~^~~~~~~~~~