#include "cmp.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define endl '\n'
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define FordE(i, l, r) for (int i = l; i >= r; i--)
#define Fora(v, a) for (auto v: a)
#define bend(a) a.begin(), a.end()
#define isz(a) ((signed)a.size())
using ll = long long;
using ld = long double;
using pii = pair <int, int>;
using vi = vector <int>;
using vpii = vector <pii>;
using vvi = vector <vi>;
const int N = 12;
void remember(int a){
int ta = 0, offset = 1;
for (int i = 10; i >= 0; i -= 2){
ta = ta * 4 + ((a & (1 << (i + 1))) ? 2 : 0) + ((a & (1 << i)) ? 1 : 0);
bit_set(offset + ta);
offset += (1 << (12 - i));
}
}
int compare(int b){
int hi = 5, lo = -1;
while (hi > lo){
int mid = (hi + lo + 1) / 2;
int tb = 0, offset = 1;
for (int i = 11; i >= 2 * mid; i--){
tb = tb * 2 + ((b & (1 << i)) ? 1 : 0);
if (i % 2 == 0 and i != 2 * mid){
offset += (1 << (12 - i));
}
}
if (bit_get(offset + tb)){
hi = mid - 1;
}
else{
lo = mid;
}
}
if (lo == -1){
return 0;
}
int tb = 0, offset = 1;
for (int i = 11; i >= 2 * lo; i--){
tb = tb * 2 + ((b & (1 << i)) ? 1 : 0);
if (i % 2 == 0 and i != 2 * lo){
offset += (1 << (12 - i));
}
}
if (!(tb & 2) and !(tb & 1)){
return -1;
}
if ((tb & 2) and (tb & 1)){
return 1;
}
if (!(tb & 2) and (tb & 1)){
if (bit_get(offset + tb - 1)){
return 1;
}
else{
return -1;
}
}
if ((tb & 2) and !(tb & 1)){
if (bit_get(offset + tb + 1)){
return -1;
}
else{
return 1;
}
}
}
/*
==================================================+
INPUT: |
--------------------------------------------------|
--------------------------------------------------|
==================================================+
OUTPUT: |
--------------------------------------------------|
--------------------------------------------------|
==================================================+
*/
Compilation message
cmp.cpp: In function 'int compare(int)':
cmp.cpp:87:1: warning: control reaches end of non-void function [-Wreturn-type]
87 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1853 ms |
96044 KB |
Output is correct - maxAccess = 10, score = 100 |