답안 #26707

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
26707 2017-07-05T05:18:24 Z grands 질문 (CEOI14_question_grader) C++14
27 / 100
1939 ms 25672 KB
//#include <iostream>
//using namespace std;
int encode(int n, int x, int y) {
	unsigned int n1 = (unsigned int)n;
	unsigned int x1 = (unsigned int)x;
	unsigned int y1 = (unsigned int)y;
	unsigned int  h = 0;
	while (true){
		bool N = (n1&((unsigned int)1 << h));
		bool X = (x1&((unsigned int)1 << h));
		bool Y = (y1&((unsigned int)1 << h));
		//cout << n << ' ' << x << ' ' << y << endl;
		//cout << ((unsigned int)1 << h) << endl;
		//cout << h % 2 << N << X << Y << endl;
		if ((N == X) && (X != Y)){
			return ((h+1) << 1) - 1;
		}
		if ((N == Y) && (X != Y)){
			return ((h +1)<< 1);
		}
		h++;
	}
}

int decode(int n, int q, int h) {
	bool cmp = h % 2 == 1;
	h+=1;
	h >>= 1;
	h -= 1;
	unsigned int n1 = (unsigned int)n;
	unsigned int q1 = (unsigned int)q;
	bool N = (n1&((unsigned int)1 << h));
	bool Q = (q1&((unsigned int)1 << h));
	/*	cout << ((unsigned int)1 << ret) << endl;
	cout << ret % 2 << N << X << Y << endl;*/
	if (cmp){
		if (N == Q){
			return true;
		}
		else{
			return false;
		}
	}
	else {
		if (N == Q){
			return false;
		}
		else{
			return true;
		}
	}

}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1855 ms 25672 KB Output is partially correct - maxh = 20
2 Partially correct 1939 ms 25672 KB Output is partially correct - maxh = 20