Submission #95746

# Submission time Handle Problem Language Result Execution time Memory
95746 2019-02-02T09:13:15 Z popovicirobert Question (Grader is different from the original contest) (CEOI14_question_grader) C++14
Compilation error
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));
     ^~~~~~