Submission #974202

# Submission time Handle Problem Language Result Execution time Memory
974202 2024-05-03T06:14:13 Z sleepntsheep Bitwise (BOI06_bitwise) C
10 / 100
1 ms 420 KB
#include<stdio.h>

#define N 100
int n,p,k[N],at[N+1],l[N],r[N],z;

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(int b=30;b>=0;--b)
    {
        int set=1<<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]<=(1<<b)&&(1<<b)<=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]<=(1<<b)&&(1<<b)<=r[j])++can,tuna=j;
                l[tuna]-=set,r[tuna]-=set;
            }
        }
        z|=set;
    }
    printf("%d",z);
}

Compilation message

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("%d%d",l+j,r+j);
      |             ^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Incorrect 0 ms 420 KB Output isn't correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Incorrect 0 ms 344 KB Output isn't correct
11 Incorrect 0 ms 344 KB Output isn't correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Incorrect 1 ms 416 KB Output isn't correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Incorrect 0 ms 344 KB Output isn't correct
16 Incorrect 0 ms 344 KB Output isn't correct
17 Incorrect 0 ms 348 KB Output isn't correct
18 Incorrect 0 ms 348 KB Output isn't correct
19 Incorrect 0 ms 348 KB Output isn't correct
20 Incorrect 0 ms 348 KB Output isn't correct