Submission #1029732

# Submission time Handle Problem Language Result Execution time Memory
1029732 2024-07-21T08:39:46 Z coolboy19521 cmp (balkan11_cmp) C++17
100 / 100
981 ms 96596 KB
#include "cmp.h"

int d[]{1, 4097, 5121, 5377, 5441, 5457};

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

int compare(int b) {
    int l = 0, r = 6;
    while (l != r) {
        int mi = l + (r - l) / 2;
        if (bit_get((b >> mi * 2) + d[mi])) r = mi;
        else l = mi + 1;
    }
    if (0 == l) return 0;
    int ld = (b >> l * 2 - 2) & 3;
    int p = ((b >> l * 2) << 2) + d[l - 1];
    if (1 < ld) {
        if (bit_get(p + 3)) return -1;
        return 1;
    } else {
        if (bit_get(p)) return 1;
        return -1;
    }
}

Compilation message

cmp.cpp: In function 'int compare(int)':
cmp.cpp:18:26: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   18 |     int ld = (b >> l * 2 - 2) & 3;
      |                    ~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 981 ms 96596 KB Output is correct - maxAccess = 10, score = 100