//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define endl '\n'
#include "cmp.h"
void remember(int n) {
//edit this
int xx=0;
for(int i=0;i<12;i++){
if(n&(1<<i)){
xx+=(1<<(11-i));
}
}
int nn=n;
n=xx;
int ind=1;
int cur=0;
for(int i=0;i<12;i+=3){
if(n&(1<<i)){
cur+=(1<<i);
}
if(n&(1<<(i+1))){
cur+=(1<<(i+1));
}
if(n&(1<<(i+2))){
cur+=(1<<(i+2));
}
/*if(nn==1023 and cur+ind<1500){
cout<<cur<<":"<<ind<<":"<<n<<endl;
}*/
bit_set(cur+ind);
//cur*=8;
ind+=1500;
/*for(int j=0;j<=i+2;j++){
ind+=(1<<j);
}*/
}
/* if(co<=6){
for(int i=0;i<12;i++){
if(n&(1<<i)){
bit_set(i+2);
}
else{
}
}
}
else{
bit_set(1);
for(int i=0;i<12;i++){
if(n&(1<<i)){
}
else{
bit_set(i+2);
}
}
}*/
}
int kkk;
bool check(int ind,int b){
int ask=0;
for(int i=0;i<3*ind;i++){
ask+=(b&(1<<i));
}
ask+=1500*(ind-1);
/*for(int i=0;i<ind-1;i++){
ask+=(1<<(i+1));
}*/
return bit_get(ask+1);
}
int compare(int b) {
//edit this
kkk=b;
int xx=0;
for(int i=0;i<12;i++){
if(b&(1<<i)){
xx+=(1<<(11-i));
}
}
int bb=b;
b=xx;
int ind=0;
for(int i=2;i>=0;i--){
if(ind+(1<<i)>4){
continue;
}
if(check(ind+(1<<i),b)){
ind+=(1<<i);
}
}
if(ind==4){
return 0;
}
int ind2=1;
ind2+=1500*(ind);
for(int j=0;j<3*ind;j++){
ind2+=(b&(1<<j));
}
/*if(bb==1268){
cout<<ind<<endl;
}*/
for(int i=3*ind;i<=3*ind;i+=3){
int ac=0;
if(b&(1<<i)){
ac=1;
}
int bc=0;
if(b&(1<<(i+1))){
bc=2;
}
int acc=0;
if(b&(1<<(i+2))){
acc=4;
}
int su=ac+bc+acc;
// if(bit_get(ind+su)==0){
/*if(bb==1822){
cout<<i<<endl;
cout<<ac<<":"<<bc<<endl;
}*/
vector<int> cc;
vector<int> dd;
for(int j=1;j<8;j++){
int xx=(su^j);
for(int jj=0;jj<3;jj++){
if((xx&(1<<jj))==(su&(1<<jj))){
continue;
}
if((xx&(1<<jj))){
dd.pb(xx);
}
else{
cc.pb(xx);
}
break;
}
/* if((su^j)<su){
cc.pb(su^j);
}
else{
dd.pb(su^j);
}*/
}
/*if(bb==1268){
cout<<su<<":"<<ind2<<endl;
for(auto j:cc){
cout<<j<<",,";
}
cout<<endl;
for(auto j:dd){
cout<<j<<",,";
}
cout<<endl;
}*/
if(cc.size()<=dd.size()){
int st=-1;
for(auto j:cc){
if(bit_get(ind2+j*(1<<i))){
/*if(bb==1268){
cout<<(j*(1<<i))+ind2<<endl;
}*/
st=1;
break;
}
}
return st;
}
else{
int st=1;
for(auto j:dd){
if(bit_get(ind2+j*(1<<i))){
st=-1;
break;
}
}
return st;
}
/*
if(bit_get(ind+(ac^2)+(bc))==1){
int cur=(ac^2)+bc;
if(cur<ac+bc){
return 1;
}
return -1;
}
else if(bit_get(ind+(ac^2)+(bc^1))==1){
int cur=(ac^2)+(bc^1);
if(cur<ac+bc){
return 1;
}
return -1;
}
else{
int cur=(ac)+(bc^1);
if(cur<ac+bc){
return 1;
}
return -1;
}*/
// }
// ind+=8;
}
return 0;
/* int num=0;
int ind=0;
for(int i=3;i>=0;i--){
if((ind+(1<<i))>12){
continue;
}
if(check(ind+(1<<i),b)){
ind+=(1<<i);
}
}*/
/*if(bb==1268){
cout<<ind<<endl;
}*/
if(ind==12){
return 0;
}
if(b&(1<<ind)){
return 1;
}
return -1;
/*for(int i=2;i<=13;i++){
if(bit_get(i)){
num+=(1<<(i-2));
}
}
if(bit_get(1)){
num^=4095;
}
if(num>b){
return -1;
}
if(num==b){
return 0;
}*/
return 1;
}
Compilation message
cmp.cpp: In function 'void remember(int)':
cmp.cpp:20:6: warning: unused variable 'nn' [-Wunused-variable]
20 | int nn=n;
| ^~
cmp.cpp: In function 'int compare(int)':
cmp.cpp:92:6: warning: unused variable 'bb' [-Wunused-variable]
92 | int bb=b;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9372 ms |
105084 KB |
Output is correct - maxAccess = 10, score = 100 |