답안 #668509

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
668509 2022-12-04T02:52:51 Z RambaXGorilla 질문 (CEOI14_question_grader) C++17
0 / 100
7000 ms 6116 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 && j > Y) break;
            else if(j == X) x = i;
            else 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) break;
            else 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 && j > Y) break;
            else if(j == X) x = i;
            else 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) break;
            else if(j == Q) q = i;
        }
    }
    return (bool) (q & 1 << H - 1);
}

Compilation message

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

decoder.cpp: In function 'int decode(int, int, int)':
decoder.cpp:25:31: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   25 |     return (bool) (q & 1 << H - 1);
      |                             ~~^~~
decoder.cpp: In function 'int encode(int, int, int)':
decoder.cpp:13:28: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   13 |     return __builtin_ctz(x ^ (x & y)) + 1;
      |                          ~~^~~~~~~~~
decoder.cpp:13:28: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
decoder.cpp: In function 'int decode(int, int, int)':
decoder.cpp:25:12: warning: 'q' may be used uninitialized in this function [-Wmaybe-uninitialized]
   25 |     return (bool) (q & 1 << H - 1);
      |            ^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 7020 ms 6116 KB Time limit exceeded
2 Execution timed out 7051 ms 6000 KB Time limit exceeded