답안 #563065

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
563065 2022-05-16T07:03:54 Z piOOE Bali Sculptures (APIO15_sculpture) C++17
0 / 100
1 ms 212 KB
//#define _GLIBCXX_DEBUG

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//
//using namespace __gnu_pbds;
//
//template<typename T>
//using ordered_set = tree<T, null_type, less < T>, rb_tree_tag, tree_order_statistics_node_update>;

//template<typename T>
//using normal_queue = priority_queue<T, vector<T>, greater<>>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define trace(x) cout << #x << ": " << (x) << endl;
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define uniq(x) x.resize(unique(all(x)) - begin(x))
#define sz(s) ((int) size(s))
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
#define int128 __int128
#define pb push_back
#define popb pop_back
#define eb emplace_back
#define fi first
#define se second
#define itn int

typedef long long ll;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;


template<typename T>
bool ckmn(T &x, T y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}

template<typename T>
bool ckmx(T &x, T y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}

int bit(int x, int b) {
    return (x >> b) & 1;
}

int rand(int l, int r) { return (int) ((ll) rnd() % (r - l + 1)) + l; }


const ll infL = 3e18;
const int infI = 1000000000 + 7;
const int infM = 0x3f3f3f3f; //a little bigger than 1e9
const ll infML = 0x3f3f3f3f3f3f3f3fLL; //4.5e18
const int N = 2002;
const int mod = 998244353;
const ld eps = 1e-9;

int a[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, L, R;
    cin >> n >> L >> R;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    ll ans = (1LL << 60) - 1;
    if (L == 1) {
        vector<int> dp(n + 1, infI);
        for (int bt = 59; bt > -1; --bt) {
            ans ^= (1LL << bt);
            for (int i = 1; i <= n; ++i) {
                ll sum = 0;
                dp[i] = infI;
                for (int j = i - 1; j > -1; --j) {
                    sum += a[j + 1];
                    if ((sum & ans) == sum) {
                        ckmn(dp[i], dp[j] + 1);
                    }
                }
            }
            if (dp[n] > R) {
                ans ^= (1LL << bt);
            }
        }
    } else {
        vector<bitset<101>> dp(n + 1);
        dp[0][0] = true;
        for (int bt = 59; bt > -1; --bt) {
            for (int i = 1; i <= n; ++i) {
                dp[i] = 0;
            }
            ans ^= (1LL << bt);
            for (int i = 1; i <= n; ++i) {
                ll sum = 0;
                for (int j = i - 1; j > -1; --j) {
                    sum += a[j + 1];
                    if ((sum & ans) == sum) {
                        dp[i] |= (dp[j] << 1);
                    }
                }
            }
            bool ok = false;
            for (int i = L; i <= R; ++i) {
                if (dp[n][i]) {
                    ok = true;
                    break;
                }
            }
            if (!ok) {
                ans ^= (1LL << bt);
            }
        }
    }

    cout << ans;
    return 0;

}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -