제출 #1128467

#제출 시각아이디문제언어결과실행 시간메모리
1128467NurislamBali Sculptures (APIO15_sculpture)C++17
21 / 100
12 ms332 KiB
#include <bits/stdc++.h> using namespace std; template<class T, class U> inline bool chmin(T& a, const U& b) { if (a > b) { a = b; return true; } return false; } template<class T, class U> inline bool chmax(T& a, const U& b) { if (a < b) { a = b; return true; } return false; } #define pb push_back #define int long long #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define rep(i, s, f) for(int i = s; i < f; i++) //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //#define rnd(l, r) uniform_int_distribution <int> (l, r)(rng) const int inf = 3e18; int n, a, b; vector<int> pr; void sub2(){ int ans = 0, ano = 0; for(int ms = 40; ms >= 0; ms--){ vector<vector<int>> dp(n+1, vector<int> (n+1) ); dp[0][0] = 1; for(int i = 1; i <= n; i++){ for(int k = 0; k <= i; k++){ for(int j = i-1; j >= 0; j--){ if((pr[i] - pr[j]) & (ano | (1ll << ms)))continue; dp[i][k] |= dp[j][k-1]; } } } bool ok = 0; for(int i = a; i <= b; i++) if(dp[n][i])ok = 1; if(ok)ano |= (1ll << ms); else ans |= (1ll << ms); } cout << ans << '\n'; return; }; void sub1(){ int ans = 0, ano = 0; for(int ms = 40; ms >= 0; ms--){ vector<int> dp(n+1, inf); dp[0] = 0; for(int i = 1; i <= n; i++){ for(int j = 0; j < i; j++){ if((pr[i] - pr[j]) & (ano | (1ll << ms)))continue; dp[i] = min(dp[i], dp[j] + 1); } } if(dp[n] <= b)ano |= (1ll << ms); else ans |= (1ll << ms); } cout << ans << '\n'; return; }; void solve(){ cin >> n >> a >> b; vector<int> v(n);pr.pb(0); for(int &i:v){ cin >> i; pr.pb(pr.back() + i); } if(a == 1 && n <= 100)sub1(); else sub2(); }; signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr); int tt = 1; //cin >> tt; while(tt--){ solve(); }; }
#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...