Submission #610528

#TimeUsernameProblemLanguageResultExecution timeMemory
610528nohaxjustsofloBali Sculptures (APIO15_sculpture)C++17
71 / 100
1083 ms16084 KiB
#include <bits/stdc++.h> #include <iostream> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> order_set; mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count()); //uniform_int_distribution<int> gen; ///(min, max) //int random() {return gen(mt_rand);} const int mxN=2001; const int mod=998244353; const int mxlogN=40; const int mxK=26; const ll inf=1e18; const int K=600; int dp[mxN][mxN], a[mxN], n, A, B; ll check(int i, int k, ll msk) { if(i==n) return k>=A&&k<=B; if(~dp[i][k]) return dp[i][k]; ll sum=0; for(int j=i+1; j<=n; j++) { sum+=a[j-1]; if((msk&sum)==sum) if(check(j,k+1,msk)) return dp[i][k]=1; } return dp[i][k]=0; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); for(int i=0; i<mxN; i++) for(int j=0; j<mxN; j++) dp[i][j]=-1; cin >> n >> A >> B; for(int i=0; i<n; i++) cin >> a[i]; ll msk=(1LL<<(mxlogN+1))-1; for(int j=0; j<=mxlogN; j++) { msk^=check(0,0,msk^1LL<<(mxlogN-j))<<(mxlogN-j); for(int i=0; i<mxN; i++) for(int j=0; j<mxN; j++) dp[i][j]=-1; } cout << msk << "\n"; } /* 6 2 2 8 1 2 1 5 4 */
#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...