이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 2005 + 5, inf = 4000;
int t, a[maxn], dp[maxn], f[105][105];
main(){
int n, A, B;
cin >> n >> A >> B;
for(int i = 1; i <= n; i++) {
cin >> a[i];
a[i] += a[i - 1];
}
if(A == 1) {
int cur = 0, X = 0;
for(int i = 40; i >= 0; i--) {
X += 1ll << i;
for(int r = 1; r <= n; r++) {
dp[r] = inf;
for(int l = 1; l <= r; l++) {
int sum = (a[r] - a[l - 1]) & X;
if(!((sum ^ cur) & sum)) {
dp[r] = min(dp[l - 1] + 1, dp[r]);
}
}
}
if(dp[n] > B) {
cur += 1ll << i;
}
}
cout << cur;
return 0;
}
int cur = 0, X = 0;
for(int i = 40; i >= 0; i--) {
X += 1ll << i;
for(int r = 1; r <= n; r++) {
f[0][0] = 1;
for(int c = 0; c <= r; c++) f[r][c] = 0;
for(int l = 1; l <= r; l++) {
int sum = (a[r] - a[l - 1]) & X;
if(!((sum ^ cur) & sum)) {
for(int c = 1; c <= r; c++)
f[r][c] |= f[l - 1][c - 1];
}
}
}
int F = 0;
for(int c = A; c <= B; c++) F |= f[n][c];
if(!F) {
cur += 1ll << i;
}
}
cout << cur;
}
컴파일 시 표준 에러 (stderr) 메시지
sculpture.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
6 | main(){
| ^~~~| # | 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... |