제출 #455342

#제출 시각아이디문제언어결과실행 시간메모리
455342qwerasdfzxclBali Sculptures (APIO15_sculpture)C++14
100 / 100
435 ms500 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; int a[2020], dp2[2020]; bool dp[2020][2020]; void solve(int n, int r){ ll cur = 0, ans = 0; for (int i=60;i>=0;i--){ for (int j=0;j<=n;j++) fill(dp2, dp2+2020, 1e9); cur |= 1LL<<i; ll cur2 = 0; for (int j=1;j<=n;j++){ cur2 += a[j]; if ((cur2&cur)==(ans&cur2)) dp2[j] = 1; ll cur3 = 0; for (int l=j;l;l--){ cur3 += a[l]; if ((cur3&cur)==(ans&cur3)) dp2[j] = min(dp2[j], dp2[l-1]+1); } } if (dp2[n]>r) ans |= 1LL<<i; } printf("%lld\n", ans); exit(0); } int main(){ int n, l, r; scanf("%d %d %d", &n, &l, &r); for (int i=1;i<=n;i++) scanf("%d", a+i); if (l==1) solve(n, r); ll cur = 0, ans = 0; for (int i=60;i>=0;i--){ for (int j=0;j<=n;j++) fill(dp[j], dp[j]+n+1, 0); cur |= 1LL<<i; ll cur2 = 0; for (int j=1;j<=n;j++){ cur2 += a[j]; if ((cur2&cur)==(ans&cur2)) dp[j][1] = 1; for (int k=2;k<=j;k++){ ll cur3 = 0; for (int l=j;l>k-1;l--){ cur3 += a[l]; if (dp[l-1][k-1] && (cur3&cur)==(ans&cur3)) dp[j][k] = 1; } } } bool flag = 1; for (int j=l;j<=r;j++) if (dp[n][j]) flag = 0; if (flag) ans |= 1LL<<i; } printf("%lld\n", ans); return 0; }

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

sculpture.cpp: In function 'int main()':
sculpture.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     scanf("%d %d %d", &n, &l, &r);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:32:33: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     for (int i=1;i<=n;i++) scanf("%d", 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...