Submission #24860

# Submission time Handle Problem Language Result Execution time Memory
24860 2017-06-16T10:04:17 Z chpipis cmp (balkan11_cmp) C++11
91 / 100
1640 ms 82540 KB
#include "cmp.h"

const int BLOCK = (1 << 3);
const int SIZE = 12;

void remember(int n) {
    for (int i = SIZE - 3, pos = 1; i >= 0; i -= 3, pos += BLOCK) {
        int cur = (n >> i) & (BLOCK - 1);
        bit_set(pos + cur);
    }
}

int compare(int b) {
    for (int i = SIZE - 3, pos = 1; i >= 0; i -= 3, pos += BLOCK) {
        int cur = (b >> i) & (BLOCK - 1);
        if (!bit_get(pos + cur)) {
            if (cur <= 3) {
                for (int j = 0; j < cur; j++) {
                    if (bit_get(pos + j))
                        return 1;
                }
                return -1;
            } else {
                for (int j = cur + 1; j < 8; j++) {
                    if (bit_get(pos + j))
                        return -1;
                }
                return 1;
            }
        }
    }
    return 0;
}

# Verdict Execution time Memory Grader output
1 Partially correct 1640 ms 82540 KB Output is partially correct - maxAccess = 11, score = 91