답안 #387851

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
387851 2021-04-09T09:39:47 Z Nima_Naderi 질문 (CEOI14_question_grader) C++14
100 / 100
3753 ms 24436 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MXN = 1e4 + 10;
const ll LOG = 12;
ll Mask[MXN]; bool gen = 0;
void prep(ll n){
 	gen = 1; ll ts = 1;
  	for(int mask = 0; mask < (1LL << 12); mask ++){
        ll pc = __builtin_popcountll(mask);
		if(pc != 6) continue;
		Mask[ts ++] = mask;
		if(ts > n) break;
	}
}
int encode (int n, int x, int y) {
  	if(!gen) prep(n);
    int h = 0, xr = Mask[x] ^ Mask[y];
    for(int i = 0; i < LOG; i ++){
        if((xr >> i) & 1LL){
			if((Mask[x] >> i) & 1LL){
				h = i;
				h ++;
				return h;
			}
    	}
    }
	return -1;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MXN = 1e4 + 10;
const ll LOG = 12;
ll Mask[MXN]; bool gen = 0;
void prep(ll n){
 	gen = 1; ll ts = 1;
  	for(int mask = 0; mask < (1LL << 12); mask ++){
        ll pc = __builtin_popcountll(mask);
		if(pc != 6) continue;
		Mask[ts ++] = mask;
		if(ts > n) break;
	}
}
int decode (int n, int q, int h) {
  	if(!gen) prep(n);
	h --;
    q = Mask[q];
    return (((q >> h) & 1LL));
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3753 ms 24104 KB Output is correct - maxh = 12
2 Correct 3719 ms 24436 KB Output is correct - maxh = 12