# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
886819 | anha3k25cvp | Bali Sculptures (APIO15_sculpture) | C++14 | 1014 ms | 91472 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define dl double
#define st first
#define nd second
#define II pair <int, int>
using namespace std;
const int N = 1 + 2e3;
const int inf = 7 + 1e9;
int main() {
#define TASKNAME "code"
ios_base :: sync_with_stdio (0);
cin.tie (0);
if ( fopen( TASKNAME".inp", "r" ) ) {
freopen (TASKNAME".inp", "r", stdin);
freopen (TASKNAME".out", "w", stdout);
}
int n, L, R;
cin >> n >> L >> R;
vector <ll> a(n + 1, 0);
for (int i = 1; i <= n; i ++) {
cin >> a[i];
a[i] += a[i - 1];
}
ll ans = 0;
vector <int> ok(41, 0);
vector <vector <int>> OK(n + 1, vector <int> (n + 1, 1));
vector <vector <vector <int>>> g(n + 1, vector <vector <int>> (n + 1));
for (int i = 1; i <= n; i ++)
for (int j = 0; j < i; j ++) {
ll val = a[i] - a[j];
for (int pos = 0; pos < 41; pos ++)
if ((val >> pos) & 1)
g[j][i].push_back(pos);
}
while (1) {
for (int bit = -1; bit < 41; bit ++) {
vector <int> mi(n + 1, inf), ma(n + 1, 0);
mi[0] = 0;
ma[0] = 0;
for (int i = 1; i <= n; i ++)
for (int j = 0; j < i; j ++) {
if (!OK[j][i])
continue;
int check = 1;
for (int pos : g[j][i])
if (pos > bit && !ok[pos]) {
check = 0;
break;
}
if (!check)
continue;
mi[i] = min(mi[i], mi[j] + 1);
ma[i] = max(ma[i], ma[j] + 1);
}
if (mi[n] <= R && ma[n] >= L) {
if (bit < 0) {
cout << ans;
return 0;
}
for (int i = 1; i <= n; i ++)
for (int j = 0; j < i; j ++) {
if (!OK[j][i])
continue;
for (int pos : g[j][i])
if (pos > bit && !ok[pos])
OK[j][i] = 0;
}
ok[bit] = 1;
ans += (ll)1 << bit;
break;
}
}
}
return 0;
}
컴파일 시 표준 에러 (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... |