제출 #1144011

#제출 시각아이디문제언어결과실행 시간메모리
1144011alir3za_zar3Bali Sculptures (APIO15_sculpture)C++20
100 / 100
122 ms464 KiB
// Alir3za.Zar3 -> Shiraz , Iran
#include <bits/stdc++.h>
using namespace std;
#define     int     long long

const int lightN = 2e3+7 , heavyN = 1e2+7;
const int Lg = 48 , Inf = 2e18;
int n,A,B , v[lightN],out;

void iN ()
{
    cin >> n >> A >> B;
    for (int i=1; i<=n; i++)
        cin >> v[i];
    for (int i=1; i<=n; i++)
        v[i] += v[i-1];
}

bool Light_oK (int noT)
{
    int dp[n+1];
    fill_n(dp , n+1 , Inf);
    dp[0] = 0;
    for (int i=1; i<=n; i++)
        for (int j=0; j<i; j++)
            if (!( (v[i]-v[j])&noT ))
                dp[i] = min(dp[i] , dp[j]+1);
    return dp[n] <= B;
}

bool Heavy_oK (int noT)
{
    bool dp[heavyN][heavyN];
    memset(dp,false,sizeof(dp));
    dp[0][0] = true;
    for (int i=1; i<=n; i++)
        for (int j=0; j<i; j++)
            for (int k=1; k<=B; k++)
                if (dp[j][k-1] and !( (v[i]-v[j])&noT )) 
                    dp[i][k] = true;
    bool mrk = false;
    for (int i=A; i<=B; i++)
        if (dp[n][i]) mrk = true;
    return mrk;
}

void braiN ()
{
    int noT = 0;
    for (int bit=Lg; bit>=0; bit--)
    {
        noT |= 1ll<<bit;
        if (A==1 and !Light_oK(noT))
            noT ^= 1ll<<bit,
            out ^= 1ll<<bit;
        if (A>1 and !Heavy_oK(noT))
            noT ^= 1ll<<bit,
            out ^= 1ll<<bit;
    }
}

void ouT ()
{
    cout << out << '\n';
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);     cout.tie(0);

    iN();
    braiN();
    ouT();
}
#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...