제출 #1193328

#제출 시각아이디문제언어결과실행 시간메모리
1193328trvhungBali Sculptures (APIO15_sculpture)C++17
100 / 100
54 ms480 KiB
#include <bits/stdc++.h> // #include <ext/rope> // #include <ext/pb_ds/assoc_container.hpp> // using namespace __gnu_pbds; // using namespace __gnu_cxx; using namespace std; // #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> #define ll long long #define ull unsigned long long #define ld long double #define pb push_back #define bit(mask, i) ((mask >> i) & 1) #define el '\n' #define F first #define S second template <class X, class Y> bool maximize(X &x, const Y &y) { return (x < y ? x = y, 1 : 0); } template <class X, class Y> bool minimize(X &x, const Y &y) { return (x > y ? x = y, 1 : 0); } const int INF = 1e9; const ll LINF = 1e18; const int MOD = 1e9 + 7; const int MULTI = 0; const ld eps = 1e-9; const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; // R D L U const int ddx[4] = {-1, 1, 1, -1}, ddy[4] = {1, 1, -1, -1}; // UR DR DL UL const char cx[4] = {'R', 'D', 'L', 'U'}; const ll base = 31; const int nMOD = 2; const ll mods[] = {(ll)1e9 + 10777, (ll)1e9 + 19777, (ll)1e9 + 3, (ll)1e9 + 3777}; const int N = 2e3 + 5; const int LOG = 40; int n, a, b, y[N]; ll pref[N]; namespace four { const int N = 1e2 + 5; bool dp[N][N]; void solve() { ll mask = 0, res = 0; for (int t = LOG; t >= 0; --t) { mask |= (1LL << t); memset(dp, 0, sizeof(dp)); dp[0][0] = 1; for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) for (int k = 0; k < i; ++k) if (((pref[i] - pref[k]) & mask) == 0) dp[i][j] |= dp[k][j - 1]; bool c = 0; for (int i = a; i <= b; ++i) if (dp[n][i]) c = 1; if (!c) mask ^= (1LL << t), res |= (1LL << t); } cout << res; } } namespace five { int dp[N]; void solve() { ll mask = 0, res = 0; for (int t = LOG; t >= 0; --t) { mask |= (1LL << t); memset(dp, 0x3f, sizeof(dp)); dp[0] = 0; for (int i = 1; i <= n; ++i) for (int j = 0; j < i; ++j) if (((pref[i] - pref[j]) & mask) == 0) minimize(dp[i], dp[j] + 1); if (dp[n] > b) mask ^= (1LL << t), res |= (1LL << t); } cout << res; } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> a >> b; for (int i = 1; i <= n; ++i) cin >> y[i]; for (int i = 1; i <= n; ++i) pref[i] = pref[i - 1] + y[i]; if (a != 1) return four::solve(), 0; five::solve(); return 0; }
#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...