이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define de(x,y) cout<<#x<<" :"<<x<<y;
#define int long long
typedef pair<int,int> pii;
const int maxn = 1e2+5;
int arr[maxn], ans = 0, n, A, B;
int pre[maxn];
int two[60];
void solve() {
int dp[maxn][maxn];
int digit = __lg(pre[n]);
for(int x=digit; x>=0; x--) {
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for(int i=1; i<=n; i++) {
for(int j=1; j<=i; j++) {
for(int k=0; k<i; k++) {
if(dp[k][j-1]) {
int tmp = pre[i] - pre[k];
if((tmp & (two[x])) == 0 && ((ans & two[x+1]) ^ (tmp & two[x+1]) == 0) ) {
dp[i][j] = 1;
}
}
}
}
}
ans += two[x];
for(int i=A; i<=B; i++) {
if(dp[n][i]) {
ans -= two[x];
break;
}
}
}
}
main() {
// int n, A, B;
cin >> n >> A >> B;
two[0] = 1;
for(int i=1; i<=50; i++) {
two[i] = two[i-1] * 2;
}
pre[0] = 0;
for(int i=1; i<=n; i++) {
cin >> arr[i];
pre[i] = pre[i-1] + arr[i];
}
solve();
cout << ans << "\n";
}
컴파일 시 표준 에러 (stderr) 메시지
sculpture.cpp: In function 'void solve()':
sculpture.cpp:28:72: warning: suggest parentheses around comparison in operand of '^' [-Wparentheses]
if((tmp & (two[x])) == 0 && ((ans & two[x+1]) ^ (tmp & two[x+1]) == 0) ) {
~~~~~~~~~~~~~~~~~^~~~
sculpture.cpp: At global scope:
sculpture.cpp:44:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
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... |