# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
609719 | krit3379 | Bali Sculptures (APIO15_sculpture) | C++17 | 512 ms | 23636 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define N 2005
long long arr[N],qs[N][N],dp[N],bit;
bitset<N> ok[N],dpp[N];
int main(){
int n,a,b,i,j,k,l;
scanf("%d %d %d",&n,&a,&b);
for(i=1;i<=n;i++)scanf("%lld",&arr[i]),arr[i]+=arr[i-1];
for(i=1;i<=n;i++)for(j=i;j<=n;j++)qs[i][j]=arr[j]-arr[i-1];
if(a==1){
for(i=60;i>=0;i--){
long long x=bit|((1ll<<i)-1ll);
for(j=1;j<=n;j++)for(k=j;k<=n;k++)ok[j][k]=((qs[j][k]|x)==x);
for(j=1;j<=n;j++){
dp[j]=ok[1][j]?1:1e9;
for(k=1;k<j;k++)if(ok[k+1][j])dp[j]=min(dp[j],dp[k]+1);
}
if(dp[n]>b)bit|=1ll<<i;
}
printf("%lld",bit);
}
else{
for(i=60;i>=0;i--){
long long x=bit|((1ll<<i)-1ll);
for(j=1;j<=n;j++)for(k=j;k<=n;k++)ok[j][k]=((qs[j][k]|x)==x);
dpp[0][0]=true;
for(j=1;j<=n;j++){
for(k=1;k<=n;k++){
dpp[j][k]=false;
for(l=0;l<k;l++)if(dpp[j-1][l]&&ok[l+1][k])dpp[j][k]=true;
}
}
for(j=a;j<=b;j++)if(dpp[j][n])break;
if(j>b)bit|=1ll<<j;
}
printf("%lld",bit);
}
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... |