Submission #333919

# Submission time Handle Problem Language Result Execution time Memory
333919 2020-12-08T03:17:16 Z seedkin cmp (balkan11_cmp) C
100 / 100
2163 ms 83668 KB
#include "cmp.h"

void remember(int n) {
    int temp = n % 6;
    bit_set(temp+ 1 + 300);
    n /= 6;

    temp = n % 8;
    bit_set(temp+ 1+200);
    n /= 8;

    temp = n % 10;
    bit_set(temp+ 1+100);
    n /= 10;

    temp = n;
    bit_set(temp+ 1);
}

int compare(int b) {
    int temp[4];
    temp[3] = b % 6 + 1;
    b /= 6;
    
    temp[2] = b % 8 + 1;
    b /= 8;

    temp[1] = b % 10 + 1;
    b /= 10;

    temp[0] = b + 1;

    int r = bit_get(temp[0]);
    if(!r) {
        if(temp[0] <= 6 ) {
            for(int i = 1; i < temp[0]; i++) {
                if(bit_get(i)) return 1;
            }
            return -1;
        } else {
            for(int i = temp[0]+1; i <= 12; i++) {
                if(bit_get(i)) return -1;
            }
            return 1;
        }
    } 

    r = bit_get(temp[1] + 100);
    if(!r) {
        if(temp[1] <= 5) {
            for(int i = 1; i < temp[1]; i++) {
                if(bit_get(i+100)) return 1;
            }
            return -1;
        } else {
            for(int i = temp[1]+1; i <= 10; i++) {
                if(bit_get(i+100)) return -1;
            }
            return 1;
        }
    }

    r = bit_get(temp[2] + 200);
    if(!r) {
        if(temp[2] <= 4) {
            for(int i = 1; i < temp[2]; i++) {
                if(bit_get(i+200)) return 1;
            }
            return -1;
        } else {
            for(int i = temp[2]+1; i <= 8; i++) {
                if(bit_get(i+200)) return -1;
            }
            return 1;
        }
    }

    r = bit_get(temp[3] + 300);
    if(!r) {
        if(temp[3] <= 3) {
            for(int i = 1; i < temp[3]; i++) {
                if(bit_get(i+300)) return 1;
            }
            return -1;
        } else {
            for(int i = temp[3]+1; i <= 6; i++) {
                if(bit_get(i+300)) return -1;
            }
            return 1;
        }
    }

    return 0;
}

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