Submission #974204

# Submission time Handle Problem Language Result Execution time Memory
974204 2024-05-03T06:16:28 Z sleepntsheep Bitwise (BOI06_bitwise) C
0 / 100
1000 ms 360 KB
#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("%u",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 Execution timed out 1056 ms 360 KB Time limit exceeded
2 Execution timed out 1062 ms 348 KB Time limit exceeded
3 Execution timed out 1056 ms 348 KB Time limit exceeded
4 Execution timed out 1036 ms 348 KB Time limit exceeded
5 Execution timed out 1074 ms 348 KB Time limit exceeded
6 Execution timed out 1053 ms 348 KB Time limit exceeded
7 Execution timed out 1068 ms 348 KB Time limit exceeded
8 Execution timed out 1027 ms 344 KB Time limit exceeded
9 Execution timed out 1065 ms 348 KB Time limit exceeded
10 Execution timed out 1069 ms 348 KB Time limit exceeded
11 Execution timed out 1050 ms 348 KB Time limit exceeded
12 Execution timed out 1040 ms 344 KB Time limit exceeded
13 Execution timed out 1052 ms 348 KB Time limit exceeded
14 Execution timed out 1052 ms 348 KB Time limit exceeded
15 Execution timed out 1063 ms 348 KB Time limit exceeded
16 Execution timed out 1059 ms 348 KB Time limit exceeded
17 Execution timed out 1036 ms 344 KB Time limit exceeded
18 Execution timed out 1040 ms 344 KB Time limit exceeded
19 Execution timed out 1052 ms 348 KB Time limit exceeded
20 Execution timed out 1064 ms 348 KB Time limit exceeded