# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
846046 | vjudge1 | Bali Sculptures (APIO15_sculpture) | C++17 | 58 ms | 4392 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define task "test"
#define pii pair<int, int>
#define ll long long
#define fi first
#define se second
#define pb push_back
using namespace std;
void io() {
if(fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
}
const int inf = 1e9;
const int mod = 1e9+7;
const int nmax = 2e3+5;
int n, p, q, dp2[nmax];
ll a[nmax];
bool dp[nmax][nmax];
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
io();
cin >> n >> p >> q;
for(int i = 1; i <= n; ++i) {
cin >> a[i];
a[i] += a[i-1];
}
ll ans = (1ll << 41) - 1;
if(p == 1) {
for(int t = 40; t >= 0; --t) {
for(int i = 1; i <= n; ++i) dp2[i] = inf;
ans ^= 1ll << t;
for(int i = 1; i <= n; ++i) {
for(int k = 1; k <= i; ++k) {
if((ans | (a[i] - a[k-1])) == ans) {
dp2[i] = min(dp2[i], dp2[k-1] + 1);
}
}
}
if(dp2[n] > q) ans ^= (1ll << t);
}
}
else {
for(int t = 40; t >= 0; --t) {
memset(dp, 0, sizeof(dp));
dp[0][0] = 1; ans ^= 1ll << t;
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= n; ++j) {
for(int k = 1; k <= i; ++k) {
if((ans | (a[i] - a[k - 1])) == ans) {
dp[i][j] |= dp[k-1][j-1];
}
}
}
}
bool ok = 0;
for(int i = p; i <= q; ++i)
if(dp[n][i] == 1) ok = 1;
if (!ok) ans ^= 1ll<<t;
}
}
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |