Submission #927892

# Submission time Handle Problem Language Result Execution time Memory
927892 2024-02-15T13:45:56 Z MuntherCarrot cmp (balkan11_cmp) C++14
100 / 100
1179 ms 107344 KB
#include <bits/stdc++.h>
#include "cmp.h"
using namespace std;

// void bit_set(int add)
// int bit_get(int add);

void remember(int a){
    a += 4096;
    for(int i = 0; i < 6; i++){
        // if(_ == 535)  cout << a << endl;
        bit_set(a + 1);
        a >>= 2;
    }
}
int compare(int b){
    b += 4096;
    int l = 0, r = 5, res = -1;
    while(l <= r){
        int mid = (l + r) / 2;
        int x = (b >> (mid * 2));
        if(bit_get(x + 1) == 0){
            res = mid;
            l = mid + 1;
        }
        else{
            r = mid - 1;
        }
    }
    if(res == -1){
        return 0;
    }
    int dig = (b >> (res * 2));
    // cout << res << ' ' << (b >> (res * 2)) << endl;
    if(dig % 4 == 0){
        return -1;
    }
    if(dig % 4 == 1){
        return bit_get(dig - 1 + 1) == 1 ? 1 : -1;
    }
    if(dig % 4 == 2){
        return bit_get(dig + 1 + 1) == 1 ? -1 : 1;
    }
    if(dig % 4 == 3){
        return 1;
    }
    return 0;
}

// by me
# Verdict Execution time Memory Grader output
1 Correct 1179 ms 107344 KB Output is correct - maxAccess = 10, score = 100