Submission #23526

# Submission time Handle Problem Language Result Execution time Memory
23526 2017-05-12T10:45:54 Z TAMREF cmp (balkan11_cmp) C++11
100 / 100
1959 ms 82692 KB
#include "cmp.h"
const int sz=4;
const int x[sz]={1,6,48,480},y[sz]={6,8,10,9},pos[sz]={10,30,50,70};
void remember(int n) {
    for(int i=sz-1;i>=0;--i){
        bit_set(pos[i]+n/x[i]);
        n%=x[i];
    }
}

int compare(int b) {
    int g[6];
    for(int i=sz-1;i>=0;--i){
        g[i]=b/x[i];
        b%=x[i];
    }

    for(int i=sz-1;i>=0;--i){
        if(bit_get(pos[i]+g[i])){
            //printf("i=%d, YAY!\n",i);
            continue;
        }
        if(g[i]>y[i]-g[i]-1){
            for(int j=g[i]+1;j<y[i];j++) if(bit_get(pos[i]+j)) return -1;
            return 1;
        }
        else{
            for(int j=g[i]-1;j>=0;--j) if(bit_get(pos[i]+j)) return 1;
            return -1;
        }
    }
    return 0;
}

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