제출 #1153215

#제출 시각아이디문제언어결과실행 시간메모리
1153215zhasynBali Sculptures (APIO15_sculpture)C++20
46 / 100
3 ms332 KiB
#include <bits/stdc++.h> #define pb push_back #define pf push_front using namespace std; #define F first #define S second typedef long long ll; #define pii pair <int, int> #define pll pair <ll, ll> typedef long double ld; const ll N = 1e5 + 100, M = 4096 + 10, len = 21, inf = 1e18; const ll mod = 1e9 + 7; ll p[N], n, a, b, arr[N]; ll dp[N], nw[N]; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> a >> b; for(ll i = 1; i <= n; i++){ cin >> arr[i]; } p[0] = 1LL; for(ll i = 1; i <= 35; i++){ p[i] = p[i - 1] * 2LL; } ll x = 0, num = 0; for(ll i = 34; i >= 0; i--){ x += p[i]; num += p[i]; for(ll k = 1; k <= n; k++){ dp[k] = 0; } dp[0] = 1; //cout << i << " " << p[i] << " " << num << endl; bool was = false; for(ll gr = 1; gr <= b; gr++){ //cout << gr << " group\n"; for(ll j = gr; j <= n; j++){ if(dp[j - 1] == 0) continue; ll sm = 0; //cout << j << " " << dp[j - 1] << endl; for(ll k = j; k <= n; k++){ sm += arr[k]; //cout << sm << endl; if((sm & num) == 0) nw[k] = 1; } } for(ll k = 1; k <= n; k++){ dp[k] = nw[k]; nw[k] = 0; } if(gr >= a && dp[n]){ was = true; } } if(was) x -= p[i]; else num -= p[i]; //cout << x << " "<< num << endl << endl; } cout << x; 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...