Submission #836801

# Submission time Handle Problem Language Result Execution time Memory
836801 2023-08-24T15:55:11 Z 8pete8 Bali Sculptures (APIO15_sculpture) C++17
0 / 100
2 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=48;
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);
    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-1;b>=0;b--){
        int re=cb & (~(1<<b));//set curbit to 0;
        //print(re);
        for(int i=0;i<n;i++)dp[i]=1e13;
        for(int i=0;i<n;i++){
          if((ps[i]&re)==ps[i])dp[i]=0;
            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

sculpture.cpp: In function 'int32_t main()':
sculpture.cpp:54:9: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
   54 |     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);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 248 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Incorrect 0 ms 328 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 0 ms 324 KB Output isn't correct
6 Halted 0 ms 0 KB -