Submission #252828

# Submission time Handle Problem Language Result Execution time Memory
252828 2020-07-26T10:25:56 Z verngutz Question (Grader is different from the original contest) (CEOI14_question_grader) C++17
0 / 100
0 ms 768 KB
int encode(int n, int x, int y) {
    int least_differing_bit;
    for(int i = 0; i < 10; i++) {
        if((x & (1 << i)) ^ (y & (1 << i))) {
            least_differing_bit = i;
            break;
        }
    }
    int x0 = (x & (1 << least_differing_bit)) == 0;
    if(least_differing_bit < 8) {
        return least_differing_bit | (x0 << 3);
    } else {
        return (least_differing_bit << 1) | x0;
    }
}
int decode (int n, int q, int h) {
	int x0, least_differing_bit;
    if(h < 16) {
        x0 = h >> 3;
        least_differing_bit = h & 0b111;
    } else {
        x0 = h & 1;
        least_differing_bit = h >> 1;
    }
    return ((q >> least_differing_bit) & 1) ^ x0;
}

Compilation message

encoder.cpp: In function 'int encode(int, int, int)':
encoder.cpp:13:37: warning: 'least_differing_bit' may be used uninitialized in this function [-Wmaybe-uninitialized]
         return (least_differing_bit << 1) | x0;
                ~~~~~~~~~~~~~~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 768 KB the encoded value must be greater than or equal to 1
2 Incorrect 0 ms 640 KB the encoded value must be greater than or equal to 1