Submission #1099933

#TimeUsernameProblemLanguageResultExecution timeMemory
1099933KasymKBootfall (IZhO17_bootfall)C++17
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" using namespace std; #define ff first #define ss second #define all(v) v.begin(), v.end() #define ll long long #define pb push_back #define pii pair<int, int> #define pli pair<ll, int> #define pll pair<ll, ll> #define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i) #define wr puts("----------------") template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} const int N = 505; int a[N]; int main(){ int n; scanf("%d", &n); for(int i = 1; i <= n; ++i) scanf("%d", a+i); int sm = accumulate(a+1, a+n+1, 0); vector<int> A; for(int x = 0; x <= sm; ++x){ a[n+1] = x; bool done = 1; for(int ad = 1; ad <= n+1 and done; ++ad){ vector<int> v; for(int i = 1; i <= n+1; ++i) if(i != ad) v.pb(a[i]); int wow = accumulate(all(v), 0); vector<bool> dp(wow+1, false); dp[0] = 1; for(int &to : v) for(int i = wow; i >= to; --i) dp[i] |= dp[i-to]; done &= (wow%2 == 0 and dp[wow/2]); } if(done) A.pb(x); } printf("%d\n", (int)A.size()); for(int i : A) printf("%d ", i); puts(""); return 0; }

Compilation message (stderr)

bootfall.cpp: In function 'int main()':
bootfall.cpp:38:27: error: no match for 'operator|=' (operand types are 'std::vector<bool>::reference' and 'std::vector<bool>::reference')
   38 |                     dp[i] |= dp[i-to];
      |                     ~~~~~~^~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:45,
                 from bootfall.cpp:1:
/usr/include/c++/10/cstddef:160:3: note: candidate: 'constexpr std::byte& std::operator|=(std::byte&, std::byte)'
  160 |   operator|=(byte& __l, byte __r) noexcept
      |   ^~~~~~~~
/usr/include/c++/10/cstddef:160:20: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::byte&'
  160 |   operator|=(byte& __l, byte __r) noexcept
      |              ~~~~~~^~~
In file included 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/ios_base.h:99:3: note: candidate: 'const std::_Ios_Fmtflags& std::operator|=(std::_Ios_Fmtflags&, std::_Ios_Fmtflags)'
   99 |   operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
      |   ^~~~~~~~
/usr/include/c++/10/bits/ios_base.h:99:29: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Fmtflags&'
   99 |   operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/ios_base.h:141:3: note: candidate: 'const std::_Ios_Openmode& std::operator|=(std::_Ios_Openmode&, std::_Ios_Openmode)'
  141 |   operator|=(_Ios_Openmode& __a, _Ios_Openmode __b)
      |   ^~~~~~~~
/usr/include/c++/10/bits/ios_base.h:141:29: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Openmode&'
  141 |   operator|=(_Ios_Openmode& __a, _Ios_Openmode __b)
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/ios_base.h:181:3: note: candidate: 'const std::_Ios_Iostate& std::operator|=(std::_Ios_Iostate&, std::_Ios_Iostate)'
  181 |   operator|=(_Ios_Iostate& __a, _Ios_Iostate __b)
      |   ^~~~~~~~
/usr/include/c++/10/bits/ios_base.h:181:28: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Iostate&'
  181 |   operator|=(_Ios_Iostate& __a, _Ios_Iostate __b)
      |              ~~~~~~~~~~~~~~^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:105,
                 from bootfall.cpp:1:
/usr/include/c++/10/future:167:18: note: candidate: 'std::launch& std::operator|=(std::launch&, std::launch)'
  167 |   inline launch& operator|=(launch& __x, launch __y)
      |                  ^~~~~~~~
/usr/include/c++/10/future:167:37: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::launch&'
  167 |   inline launch& operator|=(launch& __x, launch __y)
      |                             ~~~~~~~~^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:127,
                 from bootfall.cpp:1:
/usr/include/c++/10/charconv:680:3: note: candidate: 'constexpr std::chars_format& std::operator|=(std::chars_format&, std::chars_format)'
  680 |   operator|=(chars_format& __lhs, chars_format __rhs) noexcept
      |   ^~~~~~~~
/usr/include/c++/10/charconv:680:28: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::chars_format&'
  680 |   operator|=(chars_format& __lhs, chars_format __rhs) noexcept
      |              ~~~~~~~~~~~~~~^~~~~
bootfall.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
bootfall.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         scanf("%d", a+i);
      |         ~~~~~^~~~~~~~~~~