Submission #668515

# Submission time Handle Problem Language Result Execution time Memory
668515 2022-12-04T03:03:02 Z RambaXGorilla Question (Grader is different from the original contest) (CEOI14_question_grader) C++17
100 / 100
4149 ms 24220 KB
using namespace std;
int conv[930] = {};
void fillConv(){
    if(conv[1]) return;
    for(int i = 0, j = 0;i < 1 << 12;i++){
        if(__builtin_popcount(i) == 6){
            j++;
            conv[j] = i;
        }
    }
}

int encode(int N, int X, int Y){
    fillConv();
    return __builtin_ctz(conv[X] ^ (conv[X] & conv[Y])) + 1;
}

int decode(int N, int Q, int H){
    fillConv();
    return (bool) (conv[Q] & 1 << H - 1);
}
using namespace std;
int conv[930] = {};
void fillConv(){
    if(conv[1]) return;
    for(int i = 0, j = 0;i < 1 << 12;i++){
        if(__builtin_popcount(i) == 6){
            j++;
            conv[j] = i;
        }
    }
}

int encode(int N, int X, int Y){
    fillConv();
    return __builtin_ctz(conv[X] ^ (conv[X] & conv[Y])) + 1;
}

int decode(int N, int Q, int H){
    fillConv();
    return (bool) (conv[Q] & 1 << H - 1);
}

Compilation message

encoder.cpp: In function 'int decode(int, int, int)':
encoder.cpp:20:37: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   20 |     return (bool) (conv[Q] & 1 << H - 1);
      |                                   ~~^~~

decoder.cpp: In function 'int decode(int, int, int)':
decoder.cpp:20:37: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   20 |     return (bool) (conv[Q] & 1 << H - 1);
      |                                   ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 4061 ms 24220 KB Output is correct - maxh = 12
2 Correct 4149 ms 24064 KB Output is correct - maxh = 12