제출 #767738

#제출 시각아이디문제언어결과실행 시간메모리
767738TobBali Sculptures (APIO15_sculpture)C++14
0 / 100
1 ms308 KiB
#include <bits/stdc++.h>

#define ll long long
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pb push_back
#define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

typedef pair <ll, ll> pii;

const int N = 2e3 + 7;

ll n, a, b;
ll aa[N], ps[N], dp[N][N], dp2[N];

ll Sum(ll x, ll y) {
	if (!x) return ps[y];
	return ps[y] - ps[x-1] + 1;
}

int main () {
	cin >> n >> a >> b;
	
	for (int i = 1; i <= n; i++) {
		cin >> aa[i];
		ps[i] = ps[i-1] + aa[i];
	}
	
	if (a > 1) {
		ll cur = 0;
		for (int i = 41; i >= 0; i--) {
			memset(dp, 0, sizeof dp);
			dp[0][0] = 1;
			for (int j = 1; j <= n; j++) {
				for (int k = 1; k <= j; k++) {
					for (int l = 1; l <= b; l++) {
						if (((Sum(k, j) >> i) & (cur >> i)) == (Sum(k, j) >> i)) dp[j][l] |= dp[k-1][l-1];
					}
				}
			}
			int ok = 0;
			for (int i = a; i <= b; i++) ok |= dp[n][i];
			if (!ok) cur |= (1LL << i);
		}
		cout << cur;
	}
	else {
		ll cur = 0;
		for (int i = 41; i >= 0; i--) {
			for (int j = 1; j <= n; j++) dp2[j] = 1e18;
			for (int j = 1; j <= n; j++) {
				for (int k = 1; k <= j; k++) {
					if (((Sum(k, j) >> i) & (cur >> i)) == (Sum(k, j) >> i)) dp2[j] = min(dp2[j], dp2[k-1]+1);
				}
			}
			int ok = 0;
			if (dp2[n] > b) cur |= (1LL << i);
		}
		cout << cur;
	}

	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

sculpture.cpp: In function 'int main()':
sculpture.cpp:59:8: warning: unused variable 'ok' [-Wunused-variable]
   59 |    int ok = 0;
      |        ^~
#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...