Submission #848972

# Submission time Handle Problem Language Result Execution time Memory
848972 2023-09-13T19:02:28 Z abcvuitunggio cmp (balkan11_cmp) C++17
100 / 100
1139 ms 106476 KB
#include "cmp.h"

int num[4]={0,8,72,584};

void remember(int n){
    for (int i=0;i<4;i++)
        bit_set((n>>(i*3))+num[3-i]+1);
}

int compare(int b) {
    int l=0,r=3,kq=0;
    while (l<=r){
        int mid=(l+r)>>1;
        if (bit_get((b>>(9-mid*3))+num[mid]+1))
            l=kq=mid+1;
        else
            r=mid-1;
    }
    if (kq==4)
        return 0;
    b>>=(9-kq*3);
    if (b%8<4){
        for (int i=0;i<b%8;i++)
            if (bit_get(b/8*8+i+num[kq]+1))
                return 1;
        return -1;
    }
    for (int i=b%8+1;i<8;i++)
        if (bit_get(b/8*8+i+num[kq]+1))
            return -1;
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 1139 ms 106476 KB Output is correct - maxAccess = 10, score = 100