Submission #974231

# Submission time Handle Problem Language Result Execution time Memory
974231 2024-05-03T06:36:39 Z sleepntsheep Bitwise (BOI06_bitwise) C
35 / 100
0 ms 348 KB
#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 tuna=-8686;
            for(int j=at[i];j<at[i+1];++j)
                if(l[j]>=0&&(set&l[j]))
                    tuna=-8787;

            if (tuna==-8686)
                for(int j=at[i];j<at[i+1];++j)
                    if(set<=r[j])
                        tuna=-8787;

            if (tuna==-8686)set=0;

            /*
            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&&((1ll<<b)&l[j]))
                {
                    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("%lld",z);
}

Compilation message

bitwise.c: In function 'main':
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 time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Correct 0 ms 348 KB Output is 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 Correct 0 ms 348 KB Output is correct
11 Incorrect 0 ms 348 KB Output isn't correct
12 Correct 0 ms 348 KB Output is correct
13 Incorrect 0 ms 348 KB Output isn't correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is 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