답안 #131835

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
131835 2019-07-17T18:57:18 Z bogdan10bos 질문 (CEOI14_question_grader) C++14
100 / 100
1561 ms 124912 KB
/// "dar aparent merge sa faci orice pe pile"
#include <bits/stdc++.h>

using namespace std;

const int NMAX = 950;
const int BMAX = 12;
const int MSK = (1 << BMAX) - 1;

vector<int> v;
bool isInit = false;
void init()
{
  	isInit = true;
	for(int msk = 0; msk < (1 << BMAX); msk++)
		if( __builtin_popcount(msk) == 6 )
			v.push_back(msk);
}

int encode(int N, int x, int y)
{
  	if(!isInit)	init();
	int X = v[x - 1], Y = v[y - 1] ^ MSK;
	int H = X & Y;
	for(int i = 0; i < BMAX; i++)
		if( (H >> i) & 1 )
			return (i + 1);
 	return -1;
}
/// atunci nu cred ca am eu suficiente pile la tine :(
#include <bits/stdc++.h>

using namespace std;

const int NMAX = 950;
const int BMAX = 12;
const int MSK = (1 << BMAX) - 1;

vector<int> v;
bool isInit = false;
void init()
{
  	isInit = true;
	for(int msk = 0; msk < (1 << BMAX); msk++)
		if( __builtin_popcount(msk) == 6 )
			v.push_back(msk);
}

int decode(int N, int q, int h)
{
  	if(!isInit)	init();
	int b = h - 1;
	int Q = v[q - 1];
	if( (Q >> b) & 1 )	return 1;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1561 ms 124688 KB Output is correct - maxh = 12
2 Correct 1546 ms 124912 KB Output is correct - maxh = 12