답안 #95746

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
95746 2019-02-02T09:13:15 Z popovicirobert 질문 (CEOI14_question_grader) C++14
컴파일 오류
0 ms 0 KB
int fr[13];
int fact[13];

inline void get(int x, int sign) {
    int i;
    fact[0] = 1;
    for(i = 1; i <= 12; i++) {
        fact[i] = fact[i - 1] * i;
    }
    int last = 0;
    int sum = 0;
    for(i = 1; i <= 6; i++) {
        int cur = fact[12 - last - 1] / (fact[6 - i] * fact[6 + i - last - 1]);
        for(int j = last + 1; j <= 12; j++) {
            if(sum + cur >= x) {
                fr[j] += sign;
                last = j;
                break;
            }
            else {
                sum += cur;
                cur = cur * (6 + i - j) / (12 - j);
            }
        }
    }
}

int encode (int N, int x, int y) {
    memset(fr, 0, sizeof(fr));
    get(x, 1);
    get(y, -1);
    for(int i = 1; i <= 12; i++) {
        if(fr[i] > 0) {
            return i;
        }
    }
}
int fr[13];
int fact[13];

inline void get(int x, int sign) {
    int i;
    fact[0] = 1;
    for(i = 1; i <= 12; i++) {
        fact[i] = fact[i - 1] * i;
    }
    int last = 0;
    int sum = 0;
    for(i = 1; i <= 6; i++) {
        int cur = fact[12 - last - 1] / (fact[6 - i] * fact[6 + i - last - 1]);
        for(int j = last + 1; j <= 12; j++) {
            if(sum + cur >= x) {
                fr[j] += sign;
                last = j;
                break;
            }
            else {
                sum += cur;
                cur = cur * (6 + i - j) / (12 - j);
            }
        }
    }
}

int decode (int N, int q, int h) {
    memset(fr, 0, sizeof(fr));
    get(q, 1);
    return fr[h] > 0;
}

Compilation message

encoder.cpp: In function 'int encode(int, int, int)':
encoder.cpp:29:5: error: 'memset' was not declared in this scope
     memset(fr, 0, sizeof(fr));
     ^~~~~~
encoder.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^

decoder.cpp: In function 'int decode(int, int, int)':
decoder.cpp:29:5: error: 'memset' was not declared in this scope
     memset(fr, 0, sizeof(fr));
     ^~~~~~