답안 #552819

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
552819 2022-04-24T05:45:52 Z Aldas25 질문 (CEOI14_question_grader) C++14
0 / 100
3058 ms 24184 KB
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)

int firstBit (int x) {
    FOR(i, 0, 15)
        if (x & (1<<i))
            return i;

    return -1;
}

int encode (int n, int x, int y) {
  int b = firstBit(x ^ y);
        b++;
        //f (b == -1) exit(1);
        int code = b<<1;
        if (x & (1<<(b-1))) code++;
    return code;
}
int decode (int n, int q, int h) {
	//int q, h;
      //  cin >> q >> h;
        //if (h > 20) exit(1);
       bool one = false;
        if (h&1) one = true;
        h >>= 1;
        h--;
        bool has = false;
        if (q & (1<<h)) has = true;
        //if (has == one) cout << "yes\n";
        //else cout << "no\n";

        if (has==one) return 1;
        else return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 3030 ms 24084 KB Output is partially correct - maxh = 21
2 Partially correct 3058 ms 24184 KB Output is partially correct - maxh = 21