Submission #4695

# Submission time Handle Problem Language Result Execution time Memory
4695 2013-12-17T13:08:34 Z tncks0121 cmp (balkan11_cmp) C++
100 / 100
2120 ms 102264 KB
#include "cmp.h"

	int cnt = 0;
void remember(int n) {
	n += 4096;
	while(n > 1) {
		bit_set(n);
		n >>= 2;
		cnt ++;
	}
}

int compare(int b) {
	b += 4096;

	int low = 0, high = 6;
	int btop = -1;

	while(low <= high) {
		int mid = (low+high) >> 1;

		if(mid != 6 && !bit_get(b >> (mid*2))) {
			btop = b >> (mid*2);
			low = mid + 1;
		}else {
			high = mid - 1;
		}
	}

	if(btop == -1) return 0;
	

	switch(btop % 4) {
	case 0:
		return -1;
	case 3:
		return 1;
	case 1:
		return bit_get(btop/4*4+0) ? 1 : -1;
	case 2:
		return bit_get(btop/4*4+3) ? -1 : 1;
	}

	return 0;
}


/*

   lca
__________
|  |  |  |
A  B  C  D

A에 있다: b < a
D에 있다: b > a
B에 있다: C에 있거나 D에 있다
C에 있다: A에 있거나 B에 있다


*/
# Verdict Execution time Memory Grader output
1 Correct 2120 ms 102264 KB Output is correct - maxAccess = 10, score = 100