# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
133563 | junodeveloper | Bali Sculptures (APIO15_sculpture) | C++14 | 26 ms | 572 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define sz(x) (int)x.size()
#define fi first
#define se second
using namespace std;
int n, A, B, a[2010];
bool chk[2010][2010], chk2[2010];
inline bool f(int x,int sum,int p) {
return (~x&sum)/(1<<p)==0;
}
bool Check1 (int x, int p) {
int i,j,k,sum;
for(i=1;i<=n;i++) {
chk[i][1]=f(x,a[i],p);
for(j=2;j<=i;j++) {
chk[i][j]=false;
for(k=i-1;k>=j-1;k--) {
sum=a[i]-a[k];
if(f(x,sum,p)) {
chk[i][j]|=chk[k][j-1];
}
}
}
}
bool res=false;
for(i=A;i<=B;i++) res|=chk[n][i];
return res;
}
bool Check2(int x, int p) {
int i,j,k,sum;
for(i=1;i<=n;i++) {
chk2[i]=f(x,a[i],p);
for(k=i-1;k>=1;k--) {
sum=a[i]-a[k];
if(f(x,sum,p)) {
chk2[i]|=chk2[k];
}
}
}
return chk2[n];
}
int main() {
int task;
scanf("%d%d%d",&n,&A,&B);
if(n<=100) task=0;
else task=1;
int i;
for(i=1;i<=n;i++) {
scanf("%d",a+i);
a[i]+=a[i-1];
}
int res=0;
for(i=31;i>=0;i--) {
if(task) { if(!Check2(res,i)) res|=1<<i; }
else { if(!Check1(res,i)) res|=1<<i; }
}
printf("%d",res);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |