# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
836779 | 2023-08-24T15:38:01 Z | 8pete8 | Bali Sculptures (APIO15_sculpture) | C++14 | 1 ms | 360 KB |
#include<iostream> #include<stack> #include<map> #include<vector> #include<string> #include<unordered_map> #include <queue> #include<cstring> #include<limits.h> #include<cmath> #include<set> #include<algorithm> #include<bitset> using namespace std; #define ll long long #define f first #define endl "\n" #define s second #define pii pair<int,int> #define ppii pair<int,pii> #define pb push_back #define all(x) x.begin(),x.end() #define F(n) for(int i=0;i<n;i++) #define lb lower_bound #define p push #define fastio ios::sync_with_stdio(false);cin.tie(NULL); using namespace std; #define int long long const int mxn=3*1e5,mod=998244353,lg=46; void setIO(string name) { ios_base::sync_with_stdio(0); cin.tie(0); freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } void print(int a){ for(int i=lg;i>=0;i--)cout<<(((a&(1<<i))==0)?0:1); cout<<'\n'; } int cb=(1ll<<lg)-1; int dp[2002],ps[2002],dp2[2002][2002]; int32_t main(){ fastio int n,a,b;cin>>n>>a>>b; //find if its possible to set the ith bit 0 //if it can then we fix it vector<int>v(n+1); for(int i=1;i<=n;i++)cin>>v[i]; for(int i=1;i<=n;i++){ ps[i]=v[i]+ps[i-1]; } a--; b--; int ans=0; for(int b=lg;b>=0;b--){ //set curbit to 0; //print(re); int re=cb & (~(1ll<<b));//set curbit to 0; for(int i=0;i<=n;i++)dp[i]=1e18; dp[0]=0; for(int i=1;i<=n;i++){ for(int j=1;j<=i;j++){ int tmp=ps[i]-ps[j-1]; if((tmp&re)==tmp)dp[i]=min(dp[i],dp[j-1]+1); } } if(dp[n-1]<=b)cb=re; } //cur pos cur cut cout<<cb; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 328 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 328 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 360 KB | Output is correct |
2 | Incorrect | 0 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |