#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 "Brunolib.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
Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:69:5: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]
for(int i=now;i<n;i++)
^~~
Anna.cpp:47:10: warning: 'e' may be used uninitialized in this function [-Wmaybe-uninitialized]
e++;
~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
640 KB |
Wrong Answer [2] |
2 |
Incorrect |
4 ms |
808 KB |
Wrong Answer [4] |
3 |
Incorrect |
4 ms |
640 KB |
Wrong Answer [4] |
4 |
Incorrect |
4 ms |
892 KB |
Wrong Answer [2] |
5 |
Incorrect |
4 ms |
768 KB |
Wrong Answer [2] |
6 |
Incorrect |
3 ms |
764 KB |
Wrong Answer [2] |
7 |
Incorrect |
4 ms |
904 KB |
Wrong Answer [4] |
8 |
Incorrect |
4 ms |
904 KB |
Wrong Answer [4] |
9 |
Incorrect |
5 ms |
1028 KB |
Wrong Answer [2] |
10 |
Incorrect |
4 ms |
640 KB |
Wrong Answer [2] |
11 |
Incorrect |
5 ms |
776 KB |
Wrong Answer [2] |
12 |
Incorrect |
4 ms |
640 KB |
Wrong Answer [2] |
13 |
Incorrect |
4 ms |
640 KB |
Wrong Answer [4] |
14 |
Incorrect |
4 ms |
768 KB |
Wrong Answer [4] |
15 |
Incorrect |
4 ms |
896 KB |
Wrong Answer [2] |
16 |
Incorrect |
4 ms |
892 KB |
Wrong Answer [2] |
17 |
Incorrect |
4 ms |
768 KB |
Wrong Answer [2] |
18 |
Incorrect |
5 ms |
792 KB |
Wrong Answer [2] |
19 |
Incorrect |
4 ms |
748 KB |
Wrong Answer [2] |
20 |
Incorrect |
5 ms |
768 KB |
Wrong Answer [2] |
21 |
Incorrect |
3 ms |
776 KB |
Wrong Answer [2] |
22 |
Incorrect |
4 ms |
640 KB |
Wrong Answer [2] |
23 |
Incorrect |
4 ms |
776 KB |
Wrong Answer [2] |
24 |
Incorrect |
4 ms |
896 KB |
Wrong Answer [2] |
25 |
Incorrect |
6 ms |
776 KB |
Wrong Answer [2] |
26 |
Incorrect |
4 ms |
768 KB |
Wrong Answer [4] |
27 |
Incorrect |
4 ms |
776 KB |
Wrong Answer [2] |
28 |
Incorrect |
4 ms |
620 KB |
Wrong Answer [2] |
29 |
Incorrect |
4 ms |
776 KB |
Wrong Answer [2] |
30 |
Incorrect |
4 ms |
772 KB |
Wrong Answer [2] |
31 |
Incorrect |
5 ms |
776 KB |
Wrong Answer [4] |
32 |
Incorrect |
4 ms |
776 KB |
Wrong Answer [2] |
33 |
Incorrect |
4 ms |
900 KB |
Wrong Answer [2] |
34 |
Incorrect |
4 ms |
768 KB |
Wrong Answer [2] |
35 |
Incorrect |
4 ms |
888 KB |
Wrong Answer [2] |
36 |
Incorrect |
4 ms |
640 KB |
Wrong Answer [2] |
37 |
Incorrect |
4 ms |
640 KB |
Wrong Answer [2] |
38 |
Incorrect |
4 ms |
776 KB |
Wrong Answer [2] |
39 |
Incorrect |
5 ms |
640 KB |
Wrong Answer [2] |
40 |
Incorrect |
5 ms |
776 KB |
Wrong Answer [2] |