Submission #43944

# Submission time Handle Problem Language Result Execution time Memory
43944 2018-03-28T12:56:27 Z dhkim0225 cmp (balkan11_cmp) C++14
0 / 100
1690 ms 87928 KB
#include "cmp.h"

void remember(int n) {
	n = n + 1;

	int target = 2048;
	int shift = 10;

	while (true) {
		if (shift == -2) {
			bit_set(4096);
			break;
		}
		if (target < n) {
			bit_set(target);
			target += (1 << shift);
		}
		else if (target > n) {
			bit_set(target);
			target -= (1 << shift);
		}
		else {
			bit_set(target);
			break;
		}
		shift--;
	}
}

int compare(int b) {
	int target = 2048;
	int shift = 10;

	if (bit_get(target) == 1) {
		while (true) {
			if (shift == -1)
				break;
			else if (shift == -2) {
				target++;
				break;
			}
			if (bit_get(target + (1 << shift)))
				target += (1 << shift);
			else if (bit_get(target - (1 << shift)))
				target -= (1 << shift);
			else
				break;
			shift--;
		}
	}
	if (target - 1> b)
		return -1;
	else if (target - 1 < b)
		return 1;
	else
		return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1690 ms 87928 KB ZERO POINTS: For a=4095 and b=4094, correct answer is -1, got 0