Submission #1369799

#TimeUsernameProblemLanguageResultExecution timeMemory
1369799Avianshcmp (balkan11_cmp)C++20
100 / 100
654 ms104892 KiB
#include "cmp.h"
#include <bits/stdc++.h>

using namespace std;

vector<int>delta = {1,4100,6150,7200,7800,8100};

void remember(int n) {
    for(int i = 0;i<6;i++){
        bit_set((n>>(2*i))+delta[i]);
    }
}

int compare(int b) {
    int lo = 0;
    int hi = 6;
    while(lo<hi){
        int mid = (lo+hi)/2;
        if(bit_get((b>>(2*mid))+delta[mid])){
            hi=mid;
        }
        else{
            lo=mid+1;
        }
    }
    if(lo==0){
        //equality handled
        return 0;
    }
    lo--;
    if(((b>>(2*(lo)))&3)>=2){
        //next digit is 2 or 3
        if(bit_get(((b>>(2*(lo+1)))<<2)+3+delta[lo])){
            return -1;
        }
        return 1;
    }
    else{
        //1 or 0
        if(bit_get(((b>>(2*(lo+1)))<<2)+delta[lo])){
            return 1;
        }
        return -1;
    }
}
#Result Execution timeMemoryGrader output
Fetching results...