Submission #1032181

#TimeUsernameProblemLanguageResultExecution timeMemory
1032181amine_arouacmp (balkan11_cmp)C++17
100 / 100
1343 ms99992 KiB
#include "cmp.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> delta(6 , 1);
int pow4(int n , int i )
{
    return (n >> (2 * i));
}
void remember(int n) {
  	for(int i = 1 ; i < 6 ; i++)
    {
      	delta[i] = delta[i - 1] + (1<<(2 * (7 - i)));
    }
    for(int i = 0 ; i < 6 ; i++)
    {
        bit_set(pow4(n , i)+delta[i]);
    }
}
 
int compare(int b) 
{
    int lo = 0 , hi = 7;
    while(lo + 1 < hi)
    {
        int mid = (lo + hi)/2;
        if(bit_get(delta[mid - 1] + pow4(b , mid - 1)))
            hi = mid;
        else
            lo = mid;
    }
    hi--;
    if(hi == 0)
    {
        return 0;
    }
    int nb = 4 * pow4(b , hi);
    int bit = pow4(b , hi - 1) - nb;
    if(bit == 0)
    {
        return -1;
    }
    if(bit == 3)
    {
        return 1;
    }
    if(bit == 1)
    {
        if(bit_get(delta[hi - 1] + nb))
            return 1;
        return -1;
    }
    if(bit == 2)
    {
        if(bit_get(delta[hi - 1] + nb + 3))
        {
            return -1;
        }
        return 1;
    }
}

Compilation message (stderr)

cmp.cpp: In function 'int compare(int)':
cmp.cpp:60:1: warning: control reaches end of non-void function [-Wreturn-type]
   60 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...