Submission #668508

# Submission time Handle Problem Language Result Execution time Memory
668508 2022-12-04T02:49:13 Z RambaXGorilla Question (Grader is different from the original contest) (CEOI14_question_grader) C++17
0 / 100
7000 ms 5052 KB
using namespace std;

int encode(int N, int X, int Y){
    int x, y;
    for(int i = 0, j = 0;i < 1 << 12;i++){
        if(__builtin_popcount(i) == 6){
            j++;
            if(j == X) x = i;
            if(j == Y) y = i;
        }
    }
    return __builtin_ctz(x ^ (x & y)) + 1;
}

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

int encode(int N, int X, int Y){
    int x, y;
    for(int i = 0, j = 0;i < 1 << 12;i++){
        if(__builtin_popcount(i) == 6){
            j++;
            if(j == X) x = i;
            if(j == Y) y = i;
        }
    }
    return __builtin_ctz(x ^ (x & y)) + 1;
}

int decode(int N, int Q, int H){
    int q;
    for(int i = 0, j = 0;i < 1 << 12;i++){
        if(__builtin_popcount(i) == 6){
            j++;
            if(j == Q) q = i;
        }
    }
    return (bool) (q & 1 << H - 1);
}

Compilation message

encoder.cpp: In function 'int decode(int, int, int)':
encoder.cpp:23:31: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   23 |     return (bool) (q & 1 << H - 1);
      |                             ~~^~~
encoder.cpp: In function 'int encode(int, int, int)':
encoder.cpp:12:28: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   12 |     return __builtin_ctz(x ^ (x & y)) + 1;
      |                          ~~^~~~~~~~~
encoder.cpp:12:28: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
encoder.cpp: In function 'int decode(int, int, int)':
encoder.cpp:23:12: warning: 'q' may be used uninitialized in this function [-Wmaybe-uninitialized]
   23 |     return (bool) (q & 1 << H - 1);
      |            ^~~~~~~~~~~~~~~~~~~~~~~

decoder.cpp: In function 'int decode(int, int, int)':
decoder.cpp:23:31: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   23 |     return (bool) (q & 1 << H - 1);
      |                             ~~^~~
decoder.cpp: In function 'int encode(int, int, int)':
decoder.cpp:12:28: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   12 |     return __builtin_ctz(x ^ (x & y)) + 1;
      |                          ~~^~~~~~~~~
decoder.cpp:12:28: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
decoder.cpp: In function 'int decode(int, int, int)':
decoder.cpp:23:12: warning: 'q' may be used uninitialized in this function [-Wmaybe-uninitialized]
   23 |     return (bool) (q & 1 << H - 1);
      |            ^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 7023 ms 5052 KB Time limit exceeded
2 Execution timed out 7038 ms 4796 KB Time limit exceeded