이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf 0x3F3F3F3F
const int mod = 1e9 + 7;
const int MXN = 2e3 + 5;
int n, A, B;
int a[MXN];
int _1()
{
    int x = 0, y = (1LL << 61) - 1;
    for (int b = 60; b >= 0; b--)
    {
        vector<int> dp(n + 1, inf);
        dp[0] = 0;
        x |= (1LL << b);
        for (int i = 1; i <= n; i++)
        {
            int s = 0;
            for (int j = i; j >= 1; j--)
            {
                s += a[j];
                if ((s & x)) continue;
                dp[i] = min(dp[i], dp[j - 1] + 1);
            }
        }
        if (dp[n] > B) x ^= (1LL << b);
    }
    return y - x;
}
int _2()
{
    return 0;
}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> A >> B;
    for (int i = 1; i <= n; i++) cin >> a[i];
    cout << (A == 1 ? _1() : _2()) << '\n';
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |