Submission #1115426

# Submission time Handle Problem Language Result Execution time Memory
1115426 2024-11-20T12:56:42 Z vjudge1 Bootfall (IZhO17_bootfall) C++17
Compilation error
0 ms 0 KB
#include "bits/stdc++.h"

using namespace std;

const int mxN = 500;
const int mxSm = mxN * 2;

#define int ll

int dp[mxSm + 1];
int a[mxN];

void solve() {
	int N;
	cin >> N;

	vector<int> ans;
	for (int i = 1; i <= mxSm; i ++) {
		ans.push_back(i);
	}

	dp[0] = 1;
	int s = 0;
	for (int i = 0; i < N; i ++) {
		cin >> a[i];
		for (int j = mxSm; a[i] <= j; j --) {
			dp[j] += dp[j - a[i]];
		}
		s += a[i];
	}

	if ((s & 1) || 0 == dp[s / 2]) {
		cout << 0 << endl;
		return;
	}

	for (int i = 0; i < N; i ++) {
		s -= a[i];
		for (int j = a[i]; j <= mxSm; j ++) {
			dp[j] -= dp[j - a[i]];
		}
		for (int j = 0; j < (int)ans.size();) {
			if (s < ans[j] || ((s - ans[j]) & 1) || !dp[(s - ans[j]) / 2]) {
				if (j < (int)ans.size()) {
					swap(ans[j], ans[(int)ans.size()-1]);
				}
				ans.pop_back();
			} else {
				j ++;
			}
		}
		s += a[i];
		for (int j = mxSm; a[i] <= j; j --) {
			dp[j] += dp[j - a[i]];
		}
	}

	sort(begin(ans),end(ans));
	cout << ans.size() << endl;
	for (int i : ans) {
		cout << i << ' ';
	}
}

signed main() {
	solve();
}

Compilation message

bootfall.cpp:8:13: error: 'll' does not name a type
    8 | #define int ll
      |             ^~
bootfall.cpp:10:1: note: in expansion of macro 'int'
   10 | int dp[mxSm + 1];
      | ^~~
bootfall.cpp:8:13: error: 'll' does not name a type
    8 | #define int ll
      |             ^~
bootfall.cpp:11:1: note: in expansion of macro 'int'
   11 | int a[mxN];
      | ^~~
bootfall.cpp: In function 'void solve()':
bootfall.cpp:8:13: error: 'll' was not declared in this scope
    8 | #define int ll
      |             ^~
bootfall.cpp:14:2: note: in expansion of macro 'int'
   14 |  int N;
      |  ^~~
bootfall.cpp:15:9: error: 'N' was not declared in this scope
   15 |  cin >> N;
      |         ^
bootfall.cpp:17:12: error: template argument 2 is invalid
   17 |  vector<int> ans;
      |            ^
bootfall.cpp:18:11: error: expected ';' before 'i'
   18 |  for (int i = 1; i <= mxSm; i ++) {
      |           ^
bootfall.cpp:18:18: error: 'i' was not declared in this scope
   18 |  for (int i = 1; i <= mxSm; i ++) {
      |                  ^
bootfall.cpp:19:7: error: request for member 'push_back' in 'ans', which is of non-class type 'int'
   19 |   ans.push_back(i);
      |       ^~~~~~~~~
bootfall.cpp:22:2: error: 'dp' was not declared in this scope
   22 |  dp[0] = 1;
      |  ^~
bootfall.cpp:23:6: error: expected ';' before 's'
   23 |  int s = 0;
      |      ^
bootfall.cpp:24:11: error: expected ';' before 'i'
   24 |  for (int i = 0; i < N; i ++) {
      |           ^
bootfall.cpp:24:18: error: 'i' was not declared in this scope
   24 |  for (int i = 0; i < N; i ++) {
      |                  ^
bootfall.cpp:25:10: error: 'a' was not declared in this scope
   25 |   cin >> a[i];
      |          ^
bootfall.cpp:26:12: error: expected ';' before 'j'
   26 |   for (int j = mxSm; a[i] <= j; j --) {
      |            ^
bootfall.cpp:26:30: error: 'j' was not declared in this scope; did you mean 'jn'?
   26 |   for (int j = mxSm; a[i] <= j; j --) {
      |                              ^
      |                              jn
bootfall.cpp:29:3: error: 's' was not declared in this scope
   29 |   s += a[i];
      |   ^
bootfall.cpp:32:7: error: 's' was not declared in this scope
   32 |  if ((s & 1) || 0 == dp[s / 2]) {
      |       ^
bootfall.cpp:37:11: error: expected ';' before 'i'
   37 |  for (int i = 0; i < N; i ++) {
      |           ^
bootfall.cpp:37:18: error: 'i' was not declared in this scope
   37 |  for (int i = 0; i < N; i ++) {
      |                  ^
bootfall.cpp:38:3: error: 's' was not declared in this scope
   38 |   s -= a[i];
      |   ^
bootfall.cpp:38:8: error: 'a' was not declared in this scope
   38 |   s -= a[i];
      |        ^
bootfall.cpp:39:12: error: expected ';' before 'j'
   39 |   for (int j = a[i]; j <= mxSm; j ++) {
      |            ^
bootfall.cpp:39:22: error: 'j' was not declared in this scope; did you mean 'jn'?
   39 |   for (int j = a[i]; j <= mxSm; j ++) {
      |                      ^
      |                      jn
bootfall.cpp:42:12: error: expected ';' before 'j'
   42 |   for (int j = 0; j < (int)ans.size();) {
      |            ^
bootfall.cpp:42:19: error: 'j' was not declared in this scope; did you mean 'jn'?
   42 |   for (int j = 0; j < (int)ans.size();) {
      |                   ^
      |                   jn
bootfall.cpp:42:28: error: expected ';' before 'ans'
   42 |   for (int j = 0; j < (int)ans.size();) {
      |                            ^~~
      |                            ;
bootfall.cpp:42:32: error: request for member 'size' in 'ans', which is of non-class type 'int'
   42 |   for (int j = 0; j < (int)ans.size();) {
      |                                ^~~~
bootfall.cpp:42:38: error: expected ')' before ';' token
   42 |   for (int j = 0; j < (int)ans.size();) {
      |       ~                              ^
      |                                      )
bootfall.cpp:42:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   42 |   for (int j = 0; j < (int)ans.size();) {
      |   ^~~
bootfall.cpp:42:39: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   42 |   for (int j = 0; j < (int)ans.size();) {
      |                                       ^
bootfall.cpp:42:39: error: expected primary-expression before ')' token
bootfall.cpp:53:12: error: expected ';' before 'j'
   53 |   for (int j = mxSm; a[i] <= j; j --) {
      |            ^
bootfall.cpp:53:30: error: 'j' was not declared in this scope; did you mean 'jn'?
   53 |   for (int j = mxSm; a[i] <= j; j --) {
      |                              ^
      |                              jn
bootfall.cpp:58:16: error: no matching function for call to 'begin(int&)'
   58 |  sort(begin(ans),end(ans));
      |                ^
In file included from /usr/include/c++/10/bits/range_access.h:36,
                 from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from bootfall.cpp:1:
/usr/include/c++/10/initializer_list:90:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>)'
   90 |     begin(initializer_list<_Tp> __ils) noexcept
      |     ^~~~~
/usr/include/c++/10/initializer_list:90:5: note:   template argument deduction/substitution failed:
bootfall.cpp:58:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   58 |  sort(begin(ans),end(ans));
      |                ^
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from bootfall.cpp:1:
/usr/include/c++/10/bits/range_access.h:51:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&)'
   51 |     begin(_Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/10/bits/range_access.h:51:5: note:   template argument deduction/substitution failed:
/usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&) [with _Container = int]':
bootfall.cpp:58:16:   required from here
/usr/include/c++/10/bits/range_access.h:51:50: error: request for member 'begin' in '__cont', which is of non-class type 'int'
   51 |     begin(_Container& __cont) -> decltype(__cont.begin())
      |                                           ~~~~~~~^~~~~
/usr/include/c++/10/bits/range_access.h:61:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&)'
   61 |     begin(const _Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/10/bits/range_access.h:61:5: note:   template argument deduction/substitution failed:
/usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&) [with _Container = int]':
bootfall.cpp:58:16:   required from here
/usr/include/c++/10/bits/range_access.h:61:56: error: request for member 'begin' in '__cont', which is of non-class type 'const int'
   61 |     begin(const _Container& __cont) -> decltype(__cont.begin())
      |                                                 ~~~~~~~^~~~~
/usr/include/c++/10/bits/range_access.h:90:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::begin(_Tp (&)[_Nm])'
   90 |     begin(_Tp (&__arr)[_Nm])
      |     ^~~~~
/usr/include/c++/10/bits/range_access.h:90:5: note:   template argument deduction/substitution failed:
bootfall.cpp:58:16: note:   mismatched types '_Tp [_Nm]' and 'int'
   58 |  sort(begin(ans),end(ans));
      |                ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from bootfall.cpp:1:
/usr/include/c++/10/valarray:1214:5: note: candidate: 'template<class _Tp> _Tp* std::begin(std::valarray<_Tp>&)'
 1214 |     begin(valarray<_Tp>& __va)
      |     ^~~~~
/usr/include/c++/10/valarray:1214:5: note:   template argument deduction/substitution failed:
bootfall.cpp:58:16: note:   mismatched types 'std::valarray<_Tp>' and 'int'
   58 |  sort(begin(ans),end(ans));
      |                ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from bootfall.cpp:1:
/usr/include/c++/10/valarray:1224:5: note: candidate: 'template<class _Tp> const _Tp* std::begin(const std::valarray<_Tp>&)'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
/usr/include/c++/10/valarray:1224:5: note:   template argument deduction/substitution failed:
bootfall.cpp:58:16: note:   mismatched types 'const std::valarray<_Tp>' and 'int'
   58 |  sort(begin(ans),end(ans));
      |                ^
bootfall.cpp:58:25: error: no matching function for call to 'end(int&)'
   58 |  sort(begin(ans),end(ans));
      |                         ^
In file included from /usr/include/c++/10/bits/range_access.h:36,
                 from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from bootfall.cpp:1:
/usr/include/c++/10/initializer_list:101:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)'
  101 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
/usr/include/c++/10/initializer_list:101:5: note:   template argument deduction/substitution failed:
bootfall.cpp:58:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   58 |  sort(begin(ans),end(ans));
      |                         ^
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from bootfall.cpp:1:
/usr/include/c++/10/bits/range_access.h:71:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   71 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/10/bits/range_access.h:71:5: note:   template argument deduction/substitution failed:
/usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&) [with _Container = int]':
bootfall.cpp:58:25:   required from here
/usr/include/c++/10/bits/range_access.h:71:48: error: request for member 'end' in '__cont', which is of non-class type 'int'
   71 |     end(_Container& __cont) -> decltype(__cont.end())
      |                                         ~~~~~~~^~~
/usr/include/c++/10/bits/range_access.h:81:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   81 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/10/bits/range_access.h:81:5: note:   template argument deduction/substitution failed:
/usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&) [with _Container = int]':
bootfall.cpp:58:25:   required from here
/usr/include/c++/10/bits/range_access.h:81:54: error: request for member 'end' in '__cont', which is of non-class type 'const int'
   81 |     end(const _Container& __cont) -> decltype(__cont.end())
      |                                               ~~~~~~~^~~
/usr/include/c++/10/bits/range_access.h:100:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  100 |     end(_Tp (&__arr)[_Nm])
      |     ^~~
/usr/include/c++/10/bits/range_access.h:100:5: note:   template argument deduction/substitution failed:
bootfall.cpp:58:25: note:   mismatched types '_Tp [_Nm]' and 'int'
   58 |  sort(begin(ans),end(ans));
      |                         ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from bootfall.cpp:1:
/usr/include/c++/10/valarray:1234:5: note: candidate: 'template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)'
 1234 |     end(valarray<_Tp>& __va)
      |     ^~~
/usr/include/c++/10/valarray:1234:5: note:   template argument deduction/substitution failed:
bootfall.cpp:58:25: note:   mismatched types 'std::valarray<_Tp>' and 'int'
   58 |  sort(begin(ans),end(ans));
      |                         ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from bootfall.cpp:1:
/usr/include/c++/10/valarray:1244:5: note: candidate: 'template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
/usr/include/c++/10/valarray:1244:5: note:   template argument deduction/substitution failed:
bootfall.cpp:58:25: note:   mismatched types 'const std::valarray<_Tp>' and 'int'
   58 |  sort(begin(ans),end(ans));
      |                         ^
bootfall.cpp:59:14: error: request for member 'size' in 'ans', which is of non-class type 'int'
   59 |  cout << ans.size() << endl;
      |              ^~~~
bootfall.cpp:60:11: error: expected ';' before 'i'
   60 |  for (int i : ans) {
      |           ^
bootfall.cpp:63:1: error: expected primary-expression before '}' token
   63 | }
      | ^
bootfall.cpp:62:3: error: expected ';' before '}' token
   62 |  }
      |   ^
      |   ;
   63 | }
      | ~  
bootfall.cpp:63:1: error: expected primary-expression before '}' token
   63 | }
      | ^
bootfall.cpp:62:3: error: expected ')' before '}' token
   62 |  }
      |   ^
      |   )
   63 | }
      | ~  
bootfall.cpp:60:6: note: to match this '('
   60 |  for (int i : ans) {
      |      ^
bootfall.cpp:63:1: error: expected primary-expression before '}' token
   63 | }
      | ^