# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
974233 | sleepntsheep | Bitwise (BOI06_bitwise) | C11 | 1 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<stdio.h>
#define N 10000
int n,p,k[N],at[N+1];long long 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("%lld%lld",l+j,r+j);
}
for(long long b=31;b>=0;--b)
{
long long set=1ll<<b;
for(int i=0;i<p;++i)
{
int can=0;
for(int j=at[i];j<at[i+1];++j) can+=(set<=r[j]);
if(can==0) set=0;
}
for(int i=0;set&&i<p;++i)
{
int tuna=-8686;
for(int j=at[i];j<at[i+1];++j)
{
if(l[j]>=0&&(l[j]<=set))
{
l[j]-=set;
r[j]-=set;
tuna=-8787;
}
}
if (tuna==-8686)
{
for(int j=at[i];j<at[i+1];++j)
if(set<=r[j])
tuna=j;
l[tuna]=-2e10;
r[tuna]-=set;
}
}
z|=set;
//printf(" After bit %d\n",b); for(int j=0;j<n;++j)printf(" [%lld %lld]\n",l[j],r[j]);
}
printf("%lld",z);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |