# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
836108 | 2023-08-24T07:24:21 Z | 8pete8 | Bali Sculptures (APIO15_sculpture) | C++14 | 1 ms | 340 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=42; 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=2199023255551; 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); for(int i=0;i<n;i++)cin>>v[i]; for(int i=0;i<n;i++){ ps[i]=v[i]; if(i)ps[i]+=ps[i-1]; } a--; b--; int ans=0; for(int b=lg;b>=0;b--){ int re=cb & (~(1<<b));//set curbit to 0; //print(re); for(int i=0;i<n;i++)dp[i]=INT_MAX; if((v[0]&re)==v[0])dp[0]=0; for(int i=0;i<n;i++){ for(int j=0;j<i;j++){ int tmp=ps[i]-ps[j]; if((tmp&re)==tmp)dp[i]=min(dp[i],dp[j]+1); } } if(dp[n-1]<=b)cb=re; if(dp[n-1]>=a&&dp[n-1]<=b)ans=cb; } cout<<cb; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | 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 | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 0 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |