Submission #743749

# Submission time Handle Problem Language Result Execution time Memory
743749 2023-05-17T22:56:30 Z boyliguanhan cmp (balkan11_cmp) C++17
100 / 100
1278 ms 96024 KB
#include "cmp.h"
int pos[6]{1, 4097, 5121, 5377, 5441, 5457};
void remember(int n) {
    for(int i = 0; i < 6; i++) bit_set(pos[i]+(n>>i*2));
}
int compare(int b) {
    int l = 0, r = 6;
    while(l < r) {
        int mid = l+r>>1;
        if(bit_get(pos[mid]+(b>>mid*2)))r= mid;
        else l = mid+1;
    }
    if(!l) return 0;
    int d = b>>2*l-2&3;
    if(d>1) if(bit_get((((b>>l*2)<<2)+3)+pos[l-1])) return -1; else return 1;
    else if(bit_get(((b>>l*2)<<2)+pos[l-1])) return 1; else return -1;
}

Compilation message

cmp.cpp: In function 'int compare(int)':
cmp.cpp:9:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    9 |         int mid = l+r>>1;
      |                   ~^~
cmp.cpp:14:19: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   14 |     int d = b>>2*l-2&3;
      |                ~~~^~
# Verdict Execution time Memory Grader output
1 Correct 1278 ms 96024 KB Output is correct - maxAccess = 10, score = 100