답안 #42117

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
42117 2018-02-22T17:27:16 Z didwlvv 비교 (balkan11_cmp) C++14
100 / 100
1948 ms 94456 KB
#include "cmp.h"

void remember(int n) {
	int x = n / 480;
	bit_set(1000 + x);
	n %= 480;
	x = n / 48;
	bit_set(2000 + x);
	n %= 48;
	x = n / 6;
	bit_set(3000 + x);
	n %= 6;
	x = n;
	bit_set(4000 + x);


}

int compare(int b) {
	if (!bit_get(1000 + b / 480)) {
		int x = b / 480;
		if (x <= 5) {
			for (int i = 0; i < x; i++)if (bit_get(1000 + i))return 1;
			return -1;
		}
		else {
			for (int i = 11; i > x; i--)if (bit_get(1000 + i))return -1;
			return 1;
		}
	}
	else {
		b %= 480;
		if (!bit_get(2000 + b / 48)) {
			int x = b / 48;
			if (x <= 4) {
				for (int i = 0; i < x; i++)if (bit_get(2000 + i))return 1;
				return -1;
			}
			else {
				for (int i = 9; i > x; i--)if (bit_get(2000 + i))return -1;
				return 1;
			}
		}
		else {
			b %= 48;
			if (!bit_get(3000 + b / 6)) {
				int x = b / 6;
				if (x <= 3) {
					for (int i = 0; i < x; i++)if (bit_get(3000 + i))return 1;
					return -1;
				}
				else {
					for (int i = 7; i > x; i--)if (bit_get(3000 + i))return -1;
					return 1;
				}
			}
			else{
				b %= 6;
				if (!bit_get(4000 + b)) {
					int x = b;
					if (x <= 2) {
						for (int i = 0; i < x; i++)if (bit_get(4000 + i))return 1;
						return -1;
					}
					else {
						for (int i = 5; i > x; i--)if (bit_get(4000 + i))return -1;
						return 1;
					}
				}
				else {
					return 0;
				}
			}
		}
	
	}

}

# 결과 실행 시간 메모리 Grader output
1 Correct 1948 ms 94456 KB Output is correct - maxAccess = 10, score = 100