답안 #257587

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
257587 2020-08-04T12:40:12 Z doowey 질문 (CEOI14_question_grader) C++14
100 / 100
3894 ms 48320 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 940;
int mask[N];
int cnt = 0;

void gen(){
    cnt = 0;
    for(int i = 0 ; i < (1 << 12); i ++ ){
        if(__builtin_popcount(i) == 6){
            mask[++cnt]=i;
        }
    }
}

int encode (int n, int x, int y) {
    if(mask[1] == 0)
        gen();
    for(int i = 0 ; i < 12; i ++ ){
        if((mask[x] & (1 << i)) && !(mask[y] & (1 << i))){
            return i + 1;
        }
    }
    return -1;
}
#include <bits/stdc++.h>

using namespace std;

const int NN = 940;
int mi[NN];
int cc;

void gen0(){
    cc = 0;
    for(int i = 0; i < (1 << 12); i ++ ){
        if(__builtin_popcount(i) == 6){
            mi[++cc]=i;
        }
    }
}

int decode (int n, int q, int h) {
    if(mi[1] == 0){
        gen0();
    }
    h--;
    int msk = mi[q];
    if((msk & (1 << h))) return true;
    else return false;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3894 ms 48320 KB Output is correct - maxh = 12
2 Correct 3814 ms 48088 KB Output is correct - maxh = 12