# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
23046 | Bruteforceman | Bali Sculptures (APIO15_sculpture) | C++11 | 99 ms | 2092 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
int a[2005];
int dp[2005];
int n, A, B;
typedef long long Long;
Long p[2005];
const int bit = 42;
long long mask;
const int inf = 1e8;
void solve (int x) {
mask ^= 1LL << x;
for(int i = 1; i <= n; i++) {
dp[i] = inf;
for(int j = 0; j < i; j++) {
long long sum = p[i] - p[j];
if((sum | mask) == mask) dp[i] = min(dp[i], dp[j] + 1);
}
}
if(dp[n] > B) {
mask |= (1LL << x);
}
}
int xp[105][105];
void fuck(int x) {
mask ^= 1LL << x;
memset(xp, 0, sizeof xp);
xp[0][0] = 1;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= i; j++) {
for(int k = 0; k < i; k++) {
long long sum = p[i] - p[k];
if((sum | mask) == mask) {
xp[i][j] |= xp[k][j - 1];
}
}
}
}
int cnt = 0;
for(int i = A; i <= B; i++) {
cnt |= xp[n][i];
}
if(!cnt) {
mask |= 1LL << x;
}
}
int main(int argc, char const *argv[])
{
scanf("%d %d %d", &n, &A, &B);
for(int i = 1; i <= n; i++) {
scanf("%d", a + i);
}
for(int i = 1; i <= n; i++) {
p[i] = p[i - 1] + a[i];
}
for(int i = 0; i <= bit; i++) {
mask |= 1LL << i;
}
for(int x = bit; x >= 0; x--) {
if(A == 1) solve(x);
else fuck(x);
}
printf("%lld\n", mask);
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... |