Submission #718274

#TimeUsernameProblemLanguageResultExecution timeMemory
718274Urvuk3Bali Sculptures (APIO15_sculpture)C++17
21 / 100
28 ms376 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int INF=1e9,MOD=1e9+7; const ll LINF=1e18; #define fi first #define se second #define pii pair<int,int> #define pll pair<ll,ll> #define mid ((l+r)/2) #define sz(a) (int((a).size())) #define all(a) a.begin(),a.end() #define endl "\n" #define pb push_back struct Line{ ll k,m,l,r,id; ll operator ()(ll x){ return k*x+m; } }; void PRINT(int x) {cerr << x;} void PRINT(ll x) {cerr << x;} void PRINT(double x) {cerr << x;} void PRINT(char x) {cerr << '\'' << x << '\'';} void PRINT(string x) {cerr << '\"' << x << '\"';} void PRINT(bool x) {cerr << (x ? "true" : "false");} void PRINT(Line f){ cerr<<f.k<<"x+"<<f.m<<" ["<<f.l<<","<<f.r<<"]"; } template<typename T,typename V> void PRINT(pair<T,V>& x){ cerr<<"{"; PRINT(x.fi); cerr<<","; PRINT(x.se); cerr<<"}"; } template<typename T> void PRINT(T &x){ int id=0; cerr<<"{"; for(auto _i:x){ cerr<<(id++ ? "," : ""); PRINT(_i); } cerr<<"}"; } void _PRINT(){ cerr<<"]\n"; } template<typename Head,typename... Tail> void _PRINT(Head h,Tail... t){ PRINT(h); if(sizeof...(t)) cerr<<", "; _PRINT(t...); } #define Debug(x...) cerr<<"["<<#x<<"]=["; _PRINT(x) ll Intersect(Line l1,Line l2){ ll ret=floor((double)(l2.m-l1.m)/double(l1.k-l2.k)); return ret; } void Solve(){ int N,A,B; cin>>N>>A>>B; if(N<=100){ vector<ll> a(N+1); for(int i=1;i<=N;i++) cin>>a[i]; vector<ll> pref(N+1,0); for(int i=1;i<=N;i++) pref[i]=pref[i-1]+a[i]; ll res=0; set<int> nparts; for(int i=1;i<=B;i++) nparts.insert(i); ll cur=0; for(ll bit=41;bit>=0;bit--){ vector<vector<int>> dp(N+1,vector<int>(B+1,0)); dp[0][0]=1; for(int i=1;i<=N;i++){ for(int p=1;p<=min(i,B);p++){ for(int j=0;j<i;j++){ bool sb=(((pref[i]-pref[j])&((1LL<<bit)|cur))==0); if(sb && dp[j][p-1]){ dp[i][p]=1; } } } } set<int> s; for(int p=1;p<=B;p++){ if(dp[N][p] && nparts.count(p)){ s.insert(p); } } if(!s.empty()){ nparts=s; cur+=(1LL<<bit); } else{ res+=(1LL<<bit); } } cout<<res<<endl; } else{ } } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; t=1; //cin>>t; while(t--){ Solve(); } return 0; } /* 6 1 3 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...