제출 #133571

#제출 시각아이디문제언어결과실행 시간메모리
133571junodeveloperBali Sculptures (APIO15_sculpture)C++14
71 / 100
1041 ms632 KiB
#include <bits/stdc++.h> #define sz(x) (int)x.size() #define fi first #define se second using namespace std; typedef long long ll; int n, A, B, D[2010]; ll a[2010]; bool chk[2010][2010]; inline bool f(ll x,ll sum,int p) { return (~x&sum)/(1ll<<p)==0; } bool Check1 (ll x, int p) { int i,j,k;ll sum; for(i=1;i<=n;i++) { chk[i][1]=f(x,a[i],p); for(j=2;j<=i;j++) { chk[i][j]=false; for(k=i-1;k>=j-1;k--) { sum=a[i]-a[k]; if(f(x,sum,p)) { chk[i][j]|=chk[k][j-1]; } } } } bool res=false; for(i=A;i<=B;i++) res|=chk[n][i]; return res; } bool Check2(ll x, int p) { int i,j; for(i=1;i<=n;i++) { D[i]=B+1; for(j=0;j<i;j++) { if(f(x,a[i]-a[j],p)) D[i]=min(D[i],D[j]+1); } } return D[n]<=B; } int main() { int task; scanf("%d%d%d",&n,&A,&B); if(n<=100) task=0; else task=1; int i; for(i=1;i<=n;i++) { scanf("%lld",a+i); a[i]+=a[i-1]; } ll res=0; for(i=41;i>=0;i--) { if(task) { if(!Check2(res,i)) res|=1ll<<i; } else { if(!Check1(res,i)) res|=1ll<<i; } } printf("%lld",res); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

sculpture.cpp: In function 'int main()':
sculpture.cpp:44:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&n,&A,&B);
  ~~~~~^~~~~~~~~~~~~~~~~~~
sculpture.cpp:49:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",a+i);
   ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...