Submission #378803

# Submission time Handle Problem Language Result Execution time Memory
378803 2021-03-17T04:31:28 Z saarang123 Bali Sculptures (APIO15_sculpture) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
const int mxn = 2002, lgn = 46;
long long y[mxn], p[mxn];
int n, a, b;

bool check(long long mask) {
	vector<int> dp(n + 1, n + 1);
	dp[0] = 0;
	for(int i = 1; i <= n; i++)
		for(int j = 0; j < i; j++)
			if((mask | (p[i] - p[j])) == mask)
				dp[i] = min(dp[i], dp[j] + 1);
	return dp[n] <= b;
}

bool fix(long long mask) {
	vector<vector<bool>> dp(n + 1, vector<bool>(n + 1));
	dp[0][0] = true;
	for(int i = 1; i <= n; i++) 
		for(int j = 1; j <= i; j++)
			for(int k = 0; k < i; k++) 
				if((mask | (p[i] - p[k])) == mask)
					dp[i][j] |= dp[k][j - 1];
	for(int i = a; i <= b; i++)
		if(dp[n][i])
			return true;
	return false;
}

signed main() {
    std::ios::sync_with_stdio(0);
    std::cout.tie(0);
    std::cin.tie(0);
    #ifdef saarang
    freopen("/home/saarang/Documents/cp/input.txt", "r", stdin);
    freopen("/home/saarang/Documents/cp/output.txt", "w", stdout);
    #endif
    cin >> n >> a >> b;
    for(int i = 1; i <= n; i++)
    	cin >> y[i];
    for(int i = 1; i <= n; i++)
    	p[i] = p[i - 1] + y[i];
    long long ans = (1LL << lgn) - 1;
    for(int bit = lgn - 1; bit >= 0; bit--) {
    	if(a == 1) {
    		if(check(ans ^ (1LL << bit)))
    			ans ^= (1LL << bit);
    	}
    	else {
    		if(fix(ans ^ (1LL << bit)))
    			ans ^= (1LL << bit);
    	}
    }
    cout << ans << '\n';
    return 0;
}

Compilation message

sculpture.cpp: In function 'bool fix(long long int)':
sculpture.cpp:24:15: error: no match for 'operator|=' (operand types are 'std::vector<bool>::reference' {aka 'std::_Bit_reference'} and 'std::vector<bool>::reference' {aka 'std::_Bit_reference'})
   24 |      dp[i][j] |= dp[k][j - 1];
      |      ~~~~~~~~~^~~~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:45,
                 from sculpture.cpp:1:
/usr/include/c++/9/cstddef:144:3: note: candidate: 'constexpr std::byte& std::operator|=(std::byte&, std::byte)'
  144 |   operator|=(byte& __l, byte __r) noexcept
      |   ^~~~~~~~
/usr/include/c++/9/cstddef:144:20: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' {aka 'std::_Bit_reference'} to 'std::byte&'
  144 |   operator|=(byte& __l, byte __r) noexcept
      |              ~~~~~~^~~
In file included from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from sculpture.cpp:1:
/usr/include/c++/9/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++/9/bits/ios_base.h:99:29: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' {aka 'std::_Bit_reference'} to 'std::_Ios_Fmtflags&'
   99 |   operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/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++/9/bits/ios_base.h:141:29: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' {aka 'std::_Bit_reference'} to 'std::_Ios_Openmode&'
  141 |   operator|=(_Ios_Openmode& __a, _Ios_Openmode __b)
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/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++/9/bits/ios_base.h:181:28: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' {aka 'std::_Bit_reference'} to 'std::_Ios_Iostate&'
  181 |   operator|=(_Ios_Iostate& __a, _Ios_Iostate __b)
      |              ~~~~~~~~~~~~~~^~~
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:105,
                 from sculpture.cpp:1:
/usr/include/c++/9/future:167:18: note: candidate: 'std::launch& std::operator|=(std::launch&, std::launch)'
  167 |   inline launch& operator|=(launch& __x, launch __y)
      |                  ^~~~~~~~
/usr/include/c++/9/future:167:37: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' {aka 'std::_Bit_reference'} to 'std::launch&'
  167 |   inline launch& operator|=(launch& __x, launch __y)
      |                             ~~~~~~~~^~~