제출 #60510

#제출 시각아이디문제언어결과실행 시간메모리
60510Flugan42Bali Sculptures (APIO15_sculpture)C++14
21 / 100
4 ms1376 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> ii; typedef vector<ii> vii; typedef long double lld; #define rep(i,a,b) for(ll i = a; i < b; i++) #define per(i,a,b) for(ll i = a; i >= b; i--) #define sz(x) (ll)(x).size() #define all(x) x.begin(),x.end() #define inf 1000000000000000000 ll n,a,b,ans; vi y; string binary(ll x){ string s = ""; while(x>0){ if (x%2) s += '1'; else s += '0'; x /= 2; } reverse(all(s)); return s; } bool solve(ll x){ //cout << binary(((1LL<<50)-1LL)^x) << endl; if (a == 1){ vi dp; dp.assign(n+1,inf); dp[0] = 0; rep(i,1,n+1){ ll cur = 0; per(j,i-1,0){ cur += y[j]; //cout << cur << " " << (cur&(((1LL<<50)-1LL)^x)) << " " << j << " " << dp[j] << endl; if ((cur&(((1LL<<50)-1LL)^x)) == 0) dp[i] = min(dp[i],dp[j]+1); } } //rep(i,0,n) cout << dp[i] << " "; //cout << endl; //cout << x << " " << dp[n] << endl; if (dp[n] <= b) return 1; return 0; } else { vector<vi> dp; vi _; _.assign(n+1,inf); dp.assign(n+1,_); rep(i,0,n) dp[i][0] = 0; dp[0][0] = 1; rep(i,0,n+1) rep(j,1,n+1){ ll cur = 0; per(k,j-1,0){ cur += y[k]; if ((cur&(((1LL<<60)-1LL)^x)) == 0) { if (dp[i-1][k]) dp[i][j] = 1; } } } rep(i,a,b+1) if (dp[i][n]) return 1; return 0; } } int main(){ cin >> n >> a >> b; y.assign(n,0); rep(i,0,n) cin >> y[i]; ans = 0; per(i,35,0) if (!solve(ans+(1LL<<i)-1LL)) ans += (1LL<<i); cout << ans << endl; }
#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...