Submission #964685

# Submission time Handle Problem Language Result Execution time Memory
964685 2024-04-17T10:33:01 Z vjudge1 cmp (balkan11_cmp) C++17
100 / 100
1442 ms 106612 KB
#include "cmp.h"


int jmp[9] = {1, 1+4, 1+4+16, 1+4+16+64, 1+4+16+64+256, 1+4+16+64+256+1024};

void remember(int n) {
    if(n==3986)
    {
        //printf("E %d\n", n);
        for(int i=5;i>=0;--i)
        {
            //printf(" [%d] : %d %d\n", i,(n>>2*i)&3, (n>>2*i)+jmp[5-i]);
        }
    }
    for(int i=5;i>=0;--i)
        bit_set((n>>2*i)+jmp[5-i]);
}

int compare(int b) {
    int lower = -1, upper = 6;
    while (upper-lower>1)
    {
        int mid=lower+(upper-lower)/2;
        int div = 5-mid;
        if (bit_get((b>>2*div)+jmp[5-div])) lower=mid;
        else upper=mid;
    }
    if (lower == 5)
        return 0;

    int P,db;

    if(lower==-1)
    {
        P=1, db = (b>>10);
    }
    else
    {
        int div=5-lower,ndiv=div-1;
        P = (b>>2*div)*4+jmp[5-(ndiv)];
        db = (b>>(2*ndiv))&3;
    }

    //printf (" %d %d\n",lower+1,db);
    if (db == 0)
        return -1;
    if (db == 3)
        return 1;
    if (db == 1)
    {
        if (bit_get(P))
            return 1;
        return -1;
    }

    //printf(" P = %d\n",P);
    if (bit_get(P+3))
        return -1;
    return 1;
}

# Verdict Execution time Memory Grader output
1 Correct 1442 ms 106612 KB Output is correct - maxAccess = 10, score = 100