| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 846303 | vjudge1 | Bali Sculptures (APIO15_sculpture) | C++17 | 1 ms | 600 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N1 = 1e2+5;
const int N2 = 2e3+5;
int n, p, q, a[N1], dp2[N2];
ll res = (1ll << 41)-1;
bool dp1[N1][N1];
void sub1() {
for(int i = 40; i >= 0; --i) {
res ^= (1ll << i);
memset(dp1, 0, sizeof(dp1));
dp1[0][0] = 1;
for(int j = 1; j <= n; ++j) {
for(int g = 1; g <= min(j, q); ++g) {
for(int k = 0; k < j; ++k) {
if(((a[j] - a[k]) & res) == (a[j] - a[k])) {
dp1[j][g] |= dp1[k][g-1];
}
}
}
}
bool ok = 0;
for(int j = p; j <= q; ++j) {
ok |= dp1[n][j];
}
if(!ok) res ^= (1ll << i);
}
cout << res;
}
void sub2() {
for(int i = 40; i >= 0; --i) {
res ^= (1ll << i);
memset(dp2, 0x3f, sizeof(dp2));
dp2[0] = 0;
for(int j = 1; j <= n; ++j) {
for(int k = 0; k < j; ++k) {
if(((a[j]-a[k]) & res) == (a[j]-a[k])) {
dp2[j] = min(dp2[j], dp2[k]+1);
}
}
}
if(dp2[n] > q) res ^= (1ll << i);
}
cout << res;
}
signed main() {
if(fopen("test.inp", "r")) {
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> p >> q;
for(int i = 1; i <= n; ++i) {
cin >> a[i];
a[i] += a[i-1];
}
if(p == 1) sub2();
else sub1();
}
컴파일 시 표준 에러 (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... | ||||
