Submission #41078

# Submission time Handle Problem Language Result Execution time Memory
41078 2018-02-12T12:45:57 Z hsb154 cmp (balkan11_cmp) C++14
46 / 100
2791 ms 104980 KB
#include "cmp.h"

void remember(int n) {
	int mask = 1 << 11;
	int me = 0;
	for (int i = 0; mask; i++) {
		if (mask&n) {
			me = me * 2 + 2;
			bit_set(me);
		}
		else {
			me = me * 2 + 1;
			bit_set(me);
		}
		mask >>= 1;
	}
}

int compare(int b) {
	int left = 1;
	int right = 12;
	int mid = (left + right) / 2;
	int ret=-2;
	while (1) {
		int mask = 1 << 12;
		int me = 0;
		mid = (left + right) / 2;
		if (left > right) {
			if (ret==-2)
				return 0;
			else
				return ret;
		}
		for (int i = 0; i<mid; i++) {
			mask >>= 1;
			if (mask&b) {
				me = me * 2 + 2;
			}
			else {
				me = me * 2 + 1;
			}
	
		}
		if (bit_get(me)) {
			left = mid + 1;
		}
		else {
			right = mid - 1;
			ret = ((mask)&b) == (mask) ? 1 : -1;
		}
	}
}

# Verdict Execution time Memory Grader output
1 Partially correct 2791 ms 104980 KB Output is partially correct - maxAccess = 16, score = 46