Submission #44098

# Submission time Handle Problem Language Result Execution time Memory
44098 2018-03-29T23:24:29 Z dhkim0225 cmp (balkan11_cmp) C++14
91 / 100
2442 ms 98504 KB
#include "cmp.h"
#include <iostream>
using namespace std;
int bases[5] = { 8, 10, 8, 4, 2 };

void remember(int n) {
	for (int i = 5; i >= 1; i--) {
		int base = bases[i - 1];
		if (n >= base) {
			int r = n % base;
			n /= base;
			bit_set(i * 1000 + r);
		}
		else if (n == 0) 
			bit_set(i * 1000);
		else {
			bit_set(i * 1000 + n);
			n = 0;
		}
	}
}

int compare(int b) {
	int converted[6] = { 0, };
	for (int i = 5; i >= 1; i--) {
		int base = bases[i - 1];
		if (b >= base) {
			converted[i] = (b % base);
			b /= base;
		}
		else {
			converted[i] = b;
			break;
		}
	}
	for (int i = 1; i <= 5; i++) {
		int base = bases[i - 1];

		if (bit_get(1000 * i + converted[i]))
			continue;
		else {
			if (converted[i] >= base/2) {
				for (int j = converted[i] + 1; j < base; j++) {
					if (bit_get(1000 * i + j))
						return -1;
				}
				return 1;
			}
			else {
				for (int j = converted[i] - 1; j >= 0; j--) {
					if (bit_get(1000 * i + j))
						return 1;
				}
				return -1;
			}
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Partially correct 2442 ms 98504 KB Output is partially correct - maxAccess = 11, score = 91