제출 #166928

#제출 시각아이디문제언어결과실행 시간메모리
166928HideoBali Sculptures (APIO15_sculpture)C++14
71 / 100
18 ms508 KiB
// Need to git gud and reach 1900+
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;

#define all(s) s.begin(), s.end()
#define ok puts("ok")
#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define pi pair < int, int >
#define prev prev123
#define next next123
#define pow pow123
#define left left123
#define right right123

const int N = 2007;
const int INF = 1e9 + 7;

ll a[N];
int n, x, y;

main(){ // If you don't know what to do, check the text box at the bottom
    cin >> n >> x >> y;
    for (int i = 1; i <= n; i++)
        scanf("%lld", &a[i]);
    x++;
    if (x == 1){
        bool dp[N];

    }
    else {
        bool dp[107][107];
        memset(dp, false, sizeof(dp));
        dp[0][0] = true;
        ll mask = 0;
        x--;
        for (ll j = 45; j >= 0; j--){
            ll submask = (mask | (1LL << j)), s = 0;
            for (int i = 1; i <= n; i++){
                dp[i][0] = false;
                for (int g = 1; g <= min(i, y); g++){
                    dp[i][g] = false;
                    s = 0;
                    for (int l = i; l >= g; l--){
                        s += a[l];
                        if (s & submask)
                            continue;
                        dp[i][g] |= dp[l - 1][g - 1];
                    }
                }
            }
            bool b = false;
            for (int i = x; i <= y; i++){
                if (dp[n][i]){
                    b = true;
                    break;
                }
            }
            if (b)
                mask = submask;
        }
        printf("%lld", (mask ^ ((1LL << 46) - 1)));
    }
}

/*
    Totally not inspired by BenQ's template
    Things you should do:
    1. Look for stupid typos in code e.g 1 instead of -1 etc
    2. Check if there is no infinite loops
    3. "Measure twice, cut once"
    4. Stay focused

    6 1 3
    8 1 2 1 5 4
*/

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

sculpture.cpp:29:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){ // If you don't know what to do, check the text box at the bottom
      ^
sculpture.cpp: In function 'int main()':
sculpture.cpp:35:14: warning: unused variable 'dp' [-Wunused-variable]
         bool dp[N];
              ^~
sculpture.cpp:32:14: 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...