Submission #455336

# Submission time Handle Problem Language Result Execution time Memory
455336 2021-08-05T22:28:53 Z qwerasdfzxcl Bali Sculptures (APIO15_sculpture) C++14
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
int a[2020];
bool dp[2020][2020];

int main(){
    int n, l, r;
    scanf("%d %d %d", &n, &l, &r);
    for (int i=1;i<=n;i++) scanf("%d", a+i);
    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) 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) 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;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d %d %d", &n, &l, &r);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:11:33: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     for (int i=1;i<=n;i++) scanf("%d", a+i);
      |                            ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -