# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
974203 | sleepntsheep | Bitwise (BOI06_bitwise) | C11 | 1091 ms | 600 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<stdio.h>
#define N 10000
int n,p,k[N],at[N+1];unsigned z,l[N],r[N];
int main()
{
scanf("%d%d",&n,&p);
for(int i=0;i<p;++i)
scanf("%d",k+i);
for(int i=0,len=0;i<p;++i)
{
at[i]=len;
at[i+1]=len+=k[i];
for(int j=at[i];j<at[i+1];++j)
scanf("%d%d",l+j,r+j);
}
for(unsigned b=31;b>=0;--b)
{
unsigned set=1u<<b;
for(int i=0;i<p;++i)
{
int can=0,tuna=0;
for(int j=at[i];j<at[i+1];++j)
if(l[j]<=set&&set<=r[j])++can,tuna=j;
if(can==0)
set=0;
}
if(set)
for(int i=0;i<p;++i)
{
int can=0,tuna=0;
for(int j=at[i];j<at[i+1];++j)
if(l[j]<=set&&set<=r[j])++can,tuna=j;
l[tuna]-=set,r[tuna]-=set;
}
z|=set;
}
printf("%d",z);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |