답안 #836786

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
836786 2023-08-24T15:42:55 Z 8pete8 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
1 ms 336 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=(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-1;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]=INT_MAX;
        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]<=b)cb=re;
    }
    //cur pos cur cut
    cout<<cb;
}

Compilation message

sculpture.cpp: In function 'int32_t main()':
sculpture.cpp:53:9: warning: unused variable 'ans' [-Wunused-variable]
   53 |     int ans=0;
      |         ^~~
sculpture.cpp: In function 'void setIO(std::string)':
sculpture.cpp:32:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:33:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 0 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 -
# 결과 실행 시간 메모리 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 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 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -