#include <bits/stdc++.h>
#include "cmp.h"
using namespace std;
void remember(int n) {
vector <int> digits;
while(n > 0) {
digits.push_back(n % 4);
n /= 4;
}
while(digits.size() < 6) {
digits.push_back(0);
}
reverse(digits.begin(), digits.end());
int base4 = 1;
for(int i = 0; i < 6; i++) {
base4 *= 4;
base4 += digits[i];
bit_set(base4);
}
}
int compare(int b) {
vector <int> digits;
while(b > 0) {
digits.push_back(b % 4);
b /= 4;
}
while(digits.size() < 6) {
digits.push_back(0);
}
reverse(digits.begin(), digits.end());
int base4;
int l = 0, r = 5, len = 0;
while(l <= r) {
int mid = (l + r) / 2;
base4 = 1;
for(int i = 0; i <= mid; i++) {
base4 *= 4;
base4 += digits[i];
}
if(bit_get(base4)) {
l = mid + 1;
len = mid + 1;
}
else {
r = mid - 1;
}
}
if(len == 6) {
return 0;
}
base4 = 1;
for(int i = 0; i < len; i++) {
base4 *= 4;
base4 += digits[i];
}
if(digits[len] >= 2) {
base4 *= 4;
base4 += 3;
if(bit_get(base4)) {
return -1;
}
return 1;
}
else {
base4 *= 4;
if(bit_get(base4)) {
return 1;
}
return -1;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3359 ms |
102200 KB |
Output is correct - maxAccess = 10, score = 100 |