# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
964683 |
2024-04-17T10:32:33 Z |
vjudge1 |
cmp (balkan11_cmp) |
C++17 |
|
0 ms |
0 KB |
#include "cmp.h"
int jmp[9] = {1, 1+4, 1+4+16, 1+4+16+64, 1+4+16+64+256, 1+4+16+64+256+1024};
void remember(int n) {
if(n==3986)
{
//printf("E %d\n", n);
for(int i=5;i>=0;--i)
{
//printf(" [%d] : %d %d\n", i,(n>>2*i)&3, (n>>2*i)+jmp[5-i]);
}
}
for(int i=5;i>=0;--i)
bit_set((n>>2*i)+jmp[5-i]);
}
int compare(int b) {
int lower = -1, upper = 6;
while (upper-lower>1)
{
int mid=lower+(upper-lower)/2;
int div = 5-mid;
if (bit_get((b>>2*div)+jmp[5-div])) lower=mid;
else upper=mid;
}
if (lower == 5)
return 0;
int P,db;
if(lower==-1)
{
P=1, db = (b>>10);
}
else
{
int div=5-lower,ndiv=div-1;
P = (b>>2*div)*4+jmp[5-(ndiv)];
db = (b>>(2*ndiv))&3;
}
//printf (" %d %d\n",lower+1,db);
if (db == 0)
return -1;
if (db == 3)
return 1;
if (db == 1)
{
if (bit_get(P))
return 1;
return -1;
}
printf(" P = %d\n",P);
if (bit_get(P+3))
return -1;
return 1;
}
Compilation message
cmp.cpp: In function 'int compare(int)':
cmp.cpp:56:5: error: 'printf' was not declared in this scope
56 | printf(" P = %d\n",P);
| ^~~~~~
cmp.cpp:2:1: note: 'printf' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
1 | #include "cmp.h"
+++ |+#include <cstdio>
2 |