제출 #467879

#제출 시각아이디문제언어결과실행 시간메모리
467879ymmBali Sculptures (APIO15_sculpture)C++17
100 / 100
246 ms364 KiB
/// /// Let the voice of love take you higher! /// #define _USE_MATH_DEFINES #define FAST ios::sync_with_stdio(false),cin.tie(0); #include <bits/stdc++.h> #define Loop(x, l, r) for(int x = (l); x < (r); ++x) #define LoopR(x, l, r) for(int x = (r)-1; x >= (l); --x) #define all(x) x.begin(), x.end() #define Kill(x) exit((cout << (x) << '\n', 0)) #define YN(flag) ((flag)? "YES": "NO") #define F first #define S second typedef long long ll; typedef unsigned long long ull; typedef std::pair<int,int> pii; typedef std::pair<ll ,ll > pll; using namespace std; const int N = 2010; const int sN = 110; ll a[N]; int n, l, r; bool stest(ll x) { bitset<sN> dp[sN]; dp[0][0] = 1; Loop(i,0,n) { ll sum = 0; LoopR(j,0,i+1) { sum += a[j]; if((sum|x) == x) dp[i+1] |= dp[j]<<1; } } Loop(i,l,r+1) if(dp[n][i]) return 1; return 0; } bool btest(ll x) { int dp[N]; fill(dp,dp+N,N); dp[0] = 0; Loop(i,0,n) { ll sum = 0; LoopR(j,0,i+1) { sum += a[j]; if((sum|x) == x) dp[i+1] = min(dp[i+1], dp[j]+1); } } return dp[n] <= r; } bool test(ll x){return l==1?btest(x):stest(x);} int main() { FAST; cin >> n >> l >> r; Loop(i,0,n) cin >> a[i]; ll ans = 0; LoopR(i,0,60) { ll x = ans ^ ((1ll<<i)-1); if(!test(x)) ans ^= 1ll<<i; } cout << ans << '\n'; }
#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...