Submission #100049

#TimeUsernameProblemLanguageResultExecution timeMemory
100049helloworldworldBroken Device (JOI17_broken_device)C++14
0 / 100
2070 ms384 KiB
#include "Annalib.h" void Anna( int n, long long x, int k, int p[] ){ int num[65]; int c=0; int s,e; while(x!=0){ num[c]=x%2; x/2; c++; } int cur=0; for(int i=0;i<k&&cur<c;i++){ if(i==0) s=0; else s=p[i-1]+1; e=p[i]; Set(e,0); if(e-s<1) continue; if(e-s==1){ if(num[cur]==1) Set(s,1); else Set(s,0); } else{ while(e-s>=num[cur]+1&&cur<c){ if(num[cur]==0){ Set(s,1); Set(s+1,1); s+=2; cur++; } else if(num[cur]==1){ Set(s,1); s++; cur++; } } if(e-s==1) Set(s,0); } } int now; if(cur<c){ e++; now=e; while(now<n&&cur<c){ if(num[cur]==0){ if(n-now>=2){ Set(now,1); Set(now+1,1); now+=2; cur++; } else{ Set(now,0); break; } } if(num[cur]==1){ Set(now,1); now++; cur++; } } } for(int i=now;i<n;i++) Set(i,0); return; }
#include "Annalib.h" long long Bruno( int n, int a[] ){ long long ans=0; long long p=1; for(int i=0;i<n;i++){ if(a[i]==1){ if(i<n-1){ if(a[i+1]==1){ ans+=0; p*=2; i++; } else{ ans+=p; p*=2; } } else{ ans+=p; p*=2; } } } return ans; }

Compilation message (stderr)

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:9:10: warning: statement has no effect [-Wunused-value]
         x/2;
         ~^~
Anna.cpp:69:5: warning: 'now' may be used uninitialized in this function [-Wmaybe-uninitialized]
     for(int i=now;i<n;i++)
     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...