# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
739284 | BidoTeima | Bali Sculptures (APIO15_sculpture) | C++17 | 233 ms | 4232 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
ID: BidoTeima
LANG: C++11
TASK:
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void moo(string filename);
void ACPLS(string str = "")
{
if(str=="NOF")return;
if(str.size() && str != "IIOT")
moo(str);
else if(str != "IIOT"){
#ifndef ONLINE_JUDGE
freopen("output.txt", "w", stdout);
freopen("input.txt", "r", stdin);
#endif
}
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
void moo(string fileName){
freopen((fileName+".in").c_str(),"r",stdin);
freopen((fileName+".out").c_str(),"w",stdout);
}
#define tcccc \
int tttttt/*,subtask*/; \
cin >> tttttt/* >> subtask*/; \
while (tttttt--)/*end
*/
ll ans = (1ll << 50) - 1, x = 0;
int n, a, b;
ll arr[5005];
ll sum(int l, int r){
return (!l ? arr[r] : arr[r] - arr[l - 1]);
}
bool f(){
bool dp[n + 1][n + 1]{};
dp[0][0] = 1;
if(a == 1){
int mn_group[n + 1];
memset(mn_group,-1,sizeof(mn_group));
mn_group[0] = 0;
for(int i = 0; i < n; i++){
for(int j = i; j < n; j++){
if(!(sum(i, j) & x)){
if(mn_group[i] == -1 || mn_group[i] == b)continue;
dp[j + 1][mn_group[i] + 1] |= dp[i][mn_group[i]];
if(mn_group[j + 1] == -1)mn_group[j + 1] = mn_group[i] + 1;
else mn_group[j + 1] = min(mn_group[j + 1], mn_group[i] + 1);
}
}
}
}
else{
for(int k = 0; k < n; k++){
for(int i = 0; i < n; i++){
for(int j = i; j < n; j++){
if(!(sum(i, j) & x)){
dp[j + 1][k + 1] |= dp[i][k];
}
}
}
}
}
for(int k = a; k <= b; k++){
if(dp[n][k])
return 1;
}
return 0;
}
int main()
{
//ACPLS("");
cin>>n>>a>>b;
cin>>arr[0];
for(int i = 1; i < n; i++){
cin>>arr[i]; arr[i] += arr[i - 1];
}
for(int i = 49; i >= 0; i--){
x ^= 1ll << i;
if(f())
ans ^= 1ll << i;
else
x ^= 1ll << i;
}
cout<<ans;
}
컴파일 시 표준 에러 (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... |