Submission #52616

# Submission time Handle Problem Language Result Execution time Memory
52616 2018-06-26T09:21:48 Z someone_aa cmp (balkan11_cmp) C++17
73 / 100
1988 ms 96120 KB
#include "cmp.h"
#include <vector>
using namespace std;
void remember(int n) {
    int node = 0;
    int li=0, ri=4095;
    while(li < ri) {
        int sz = ri - li + 1;
        sz = sz / 4;
        int st[4], fh[4];
        for(int i=0;i<4;i++) {
            st[i] = li + i*sz;
            fh[i] = st[i] + sz - 1;
            if(st[i] <= n && n <= fh[i]) {
                node = node * 4 + (i+1);
                li = st[i]; ri = fh[i];
            }
        }
        bit_set(node);
    }
}

int compare(int b) {
    int li=0, ri=4095;
    int node = 0;
    while(li < ri) {
        int sz = ri - li + 1;
        sz = sz / 4;
        int st[4], fh[4];
        int index = 0;
        for(int i=0;i<4;i++) {
            st[i] = li + i*sz;
            fh[i] = st[i] + sz - 1;
            if(st[i] <= b && b <= fh[i]) {
                index = i + 1;
            }
        }

        if(index == 1) {
            if(bit_get(node*4+1)) {
                li = li + (index-1)*sz;
                ri = li + sz - 1;
                node = node * 4 + 1;
            }
            else return -1;
        }
        else if(index == 2) {
            if(bit_get(node*4+2)) {
                li = li + (index-1)*sz;
                ri = li + sz - 1;
                node = node * 4 + 2;
            }
            else {
                if(bit_get(node*4+1)) return 1;
                else return -1;
            }
        }
        else if(index == 3) {
            if(bit_get(node*4+3)) {
                li = li + (index-1)*sz;
                ri = li + sz - 1;
                node = node * 4 + 3;
            }
            else {
                if(bit_get(node*4+4)) return -1;
                else return 1;
            }
        }
        else if(index == 4) {
            if(bit_get(node*4+4)) {
                li = li + (index-1)*sz;
                ri = li + sz - 1;
                node = node * 4 + 4;
            }
            else return 1;
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Partially correct 1988 ms 96120 KB Output is partially correct - maxAccess = 13, score = 73