#include "cmp.h"
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
void remember(int x){
int pre[12];
pre[9]=0;
for(int i=9;i>0;i-=3){
pre[i-3]=pre[i]+(1<<(12-i));
}
for(int i=9;i>=0;i-=3){
bit_set((x>>i)+pre[i]+1);
}
}
int compare(int x){
int pre[12];
pre[9]=0;
for(int i=9;i>0;i-=3){
pre[i-3]=pre[i]+(1<<(12-i));
}
if(bit_get(pre[0]+x+1)){
return 0;
}
int low=0,high=3;
while(low<high){
int mid=((low+high+1)>>1);
if(bit_get(1+pre[3*mid]+(x>>(3*mid)))){
high=mid-1;
}
else{
low=mid;
}
}
int bst=3*high;
x>>=bst;
if((x%8)<=3){
while((x%8)!=0){
x--;
if(bit_get(pre[bst]+x+1)){
return 1;
}
}
return -1;
}
else{
while((x%8)!=7){
x++;
if(bit_get(pre[bst]+x+1)){
return -1;
}
}
return 1;
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |