Submission #43910

# Submission time Handle Problem Language Result Execution time Memory
43910 2018-03-27T15:44:42 Z dhkim0225 cmp (balkan11_cmp) C++14
0 / 100
5 ms 5496 KB
#include "cmp.h"
#include <iostream>
using namespace std;
 
void remember(int n) {
	n = n + 1;
 
	int target = 2048;
	int cnt = 1;
	while (cnt <= 12) {
		if (target < n) {
			bit_set(target * 2 - 1);
			bit_set(target * 2);
			target += (target >> cnt);
		}
		else if (target > n) {
			bit_set(target * 2 - 1);
			target -= (target >> cnt);
		}
		else {
			bit_set(target * 2 - 1);
			break;
		}
		cnt++;
	}
}
 
int compare(int b) {
	int target = 2048;
	int cnt = 1;
 
	while (cnt <= 12) {
		if (bit_get(target * 2 - 1)) {
			if (bit_get(target * 2))
				target += (target >> cnt);
			else
				target -= (target >> cnt);
		}
		else
			break;
		cnt++;
	}
	if (target > b)
		return -1;
	else if (target < b)
		return 1;
	else
		return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 5496 KB ERROR: bit_set called more than 20 times