답안 #252827

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
252827 2020-07-26T10:24:36 Z verngutz 질문 (CEOI14_question_grader) C++17
컴파일 오류
0 ms 0 KB
int encode(int n, int x, int y) {
    int least_differing_bit;
    for(int i = 0; i < N; 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:3:24: error: 'N' was not declared in this scope
     for(int i = 0; i < N; i++) {
                        ^