답안 #969978

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
969978 2024-04-26T02:58:17 Z bachhoangxuan 질문 (CEOI14_question_grader) C++17
75 / 100
3030 ms 25192 KB
#include<bits/stdc++.h>
using namespace std;

namespace Encode{
    bool init=false;
    int mask[1005];
    void build(int N){
        int cnt=0;init=true;
        for(int i=1;i<=N;i++){
            while(true){
                int x=__builtin_popcount(cnt);
                if(x<=0 || x>=9) cnt++;
                else break;
            }
            int x=8-__builtin_popcount(cnt);
            mask[i]=cnt*8+x;cnt++;
        }
    }
}

int encode (int n, int x, int y) {
    if(!Encode::init) Encode::build(n);
    int mx=Encode::mask[x];
    int my=Encode::mask[y];
    for(int j=0;j<=12;j++) if((mx>>j&1) && !(my>>j&1)) return j+1;
    return 0;
}
#include<bits/stdc++.h>
using namespace std;

namespace Decode{
    bool init=false;
    int mask[1005];
    void build(int N){
        int cnt=0;init=true;
        for(int i=1;i<=N;i++){
            while(true){
                int x=__builtin_popcount(cnt);
                if(x<=0 || x>=9) cnt++;
                else break;
            }
            int x=8-__builtin_popcount(cnt);
            mask[i]=cnt*8+x;cnt++;
        }
    }
}

int decode (int n, int q, int h) {
	if(!Decode::init) Decode::build(n);
    return (Decode::mask[q]>>(h-1)&1);
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 2776 ms 24984 KB Output is partially correct - maxh = 13
2 Partially correct 3030 ms 25192 KB Output is partially correct - maxh = 13