Submission #974207

#TimeUsernameProblemLanguageResultExecution timeMemory
974207sleepntsheepBitwise (BOI06_bitwise)C11
10 / 100
0 ms600 KiB
#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(int b=31;b>=0;--b) { long long set=1ll<<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("%lld",z); }

Compilation message (stderr)

bitwise.c: In function 'main':
bitwise.c:24:23: warning: variable 'tuna' set but not used [-Wunused-but-set-variable]
   24 |             int can=0,tuna=0;
      |                       ^~~~
bitwise.c:8:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d%d",&n,&p);
      |     ^~~~~~~~~~~~~~~~~~~
bitwise.c:10:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         scanf("%d",k+i);
      |         ^~~~~~~~~~~~~~~
bitwise.c:16:13: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |             scanf("%lld%lld",l+j,r+j);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...