# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
463893 | Hamed5001 | Bali Sculptures (APIO15_sculpture) | C++14 | 2 ms | 332 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxN = 2e3+10;
int dp[mxN][mxN];
int N, A, B;
int Y[mxN];
ll msk, ans;
bool check() {
if (A == 1) {
vector<int> d(mxN, 1e9);
queue<int> q;
q.push(0);
d[0] = 0;
while(q.size()) {
int i = q.front();
q.pop();
ll sum = 0;
for (int j = i+1; j <= N; ++j) {
sum += Y[j];
if (d[j] == 1e9 && !(sum & msk)) {
d[j] = d[i] + 1;
q.push(j);
}
}
}
return d[N] <= B;
}
for (int i = 0; i <= N; ++i)
for (int j = 0; j <= N; ++j)
dp[i][j] = 0;
dp[0][0] = 1;
for (int i = 0; i <= N; ++i) {
for (int cnt = 0; cnt <= N; ++cnt) {
if (dp[i][cnt]) {
ll sum = 0;
for (int j = i+1; j <= N; ++j) {
sum += Y[j];
if (!(msk & sum))
dp[j][cnt+1] = 1;
}
}
}
}
for (int i = A; i <= B; ++i) {
if (dp[N][i])
return 1;
}
return 0;
}
void solve() {
cin >> N >> A >> B;
for (int i = 1; i <= N; ++i)
cin >> Y[i];
for (int bit = 50; bit >= 0; --bit) {
msk |= (1LL << bit);
if (!check())
msk ^= (1LL << bit), ans |= (1LL << bit);
}
cout << ans << endl;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
solve();
}
컴파일 시 표준 에러 (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... |