| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 44061 | zadrga | Bali Sculptures (APIO15_sculpture) | C++14 | 402 ms | 36560 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 2111
typedef long long ll;
typedef long double ld;
int n, a, b;
ll pre[maxn], arr[maxn];
ll dp2[maxn][maxn], dp3[maxn];
ll meja;
bool fun2(int x, int st){
if(x == n && a <= st && st <= b)
return 1;
if(x == n)
return 0;
ll &cur = dp2[x][st];
if(cur != -1)
return cur;
cur = 0;
for(int i = x; i < n; i++){
if( ((~meja) & (pre[i] - pre[x - 1])) == 0){
cur |= fun2(i + 1, st + 1);
}
}
return cur;
}
void solve2(){
meja = (1LL << 50) - 1;
for(int i = 49; i >= 0; i--){
memset(dp2, -1, sizeof(dp2));
meja ^= (1LL << i);
if(!fun2(0, 0)){
meja ^= (1LL << i);
}
}
printf("%lld\n", meja);
}
ll fun3(int x){
if(x == n)
return 0;
ll &cur = dp3[x];
if(cur != -1)
return cur;
cur = INF;
for(int i = x; i < n; i++){
if( ((~meja) & (pre[i] - pre[x - 1])) == 0){
cur = min(cur, 1LL + fun3(i + 1));
}
}
return cur;
}
void solve3(){
meja = (1LL << 50) - 1;
for(int i = 49; i >= 0; i--){
memset(dp3, -1, sizeof(dp3));
meja ^= (1LL << i);
if(fun3(0) > b){
meja ^= (1LL << i);
}
}
printf("%lld\n", meja);
}
int main(){
scanf("%d%d%d", &n, &a, &b);
for(int i = 0; i < n; i++){
scanf("%lld", arr + i);
if(i)
pre[i] = pre[i - 1];
pre[i] += arr[i];
}
if(a != 1)
solve2();
else
solve3();
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... | ||||
