답안 #381041

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
381041 2021-03-24T10:20:28 Z wp1270 비교 (balkan11_cmp) C++14
100 / 100
1968 ms 82668 KB
#include "cmp.h"


void remember(int n) {
	int first = n / 48;
	int second = n % 48;
	bit_set(first / 10 + 1);
	bit_set(first % 10 + 13);
	bit_set(second / 6 + 23);
	bit_set(second % 6 + 31);
}

int compare(int b) {
	int first_b = b / 48;
	int second_b = b % 48;
	int m_f = first_b / 10;
	if (bit_get(m_f + 1)) {
		int k_f = first_b % 10;
		if (bit_get(k_f + 13)) {
			int m_s = second_b / 6;
			if (bit_get(m_s + 23)) {
				int k_s = second_b % 6;
				if (bit_get(k_s + 31)) {
					return 0;
				}
				else if (k_s >= 3) {
					for (int i = k_s + 1; i <= 5; i++) {
						if (bit_get(i + 31)) return -1;
					}
					return 1;
				}
				else if (k_s < 3) {
					for (int i = k_s - 1; i >= 0; i--) {
						if (bit_get(i + 31)) return 1;
					}
					return -1;
				}
			}
			else if (m_s >= 4) {
				for (int i = m_s + 1; i <= 7; i++) {
					if (bit_get(i + 23)) return -1;
				}
				return 1;
			}
			else if (m_s < 4) {
				for (int i = m_s - 1; i >= 0; i--) {
					if (bit_get(i + 23)) return 1;
				}
				return -1;
			}
		}
		else if (k_f >= 5) {
			for (int i = k_f + 1; i <= 9; i++) {
				if (bit_get(i + 13)) return -1;
			}
			return 1;
		}
		else if (k_f < 5) {
			for (int i = k_f - 1; i >= 0; i--) {
				if (bit_get(i + 13)) return 1;
			}
			return -1;
		}
	}
	else if (m_f >= 6) {
		for (int i = m_f + 1; i <= 11; i++) {
			if (bit_get(i + 1)) return -1;
		}
		return 1;
	}
	else if (m_f < 6) {
		for (int i = m_f - 1; i >= 0; i--) {
			if (bit_get(i + 1)) return 1;
		}
		return -1;
	}
}

Compilation message

cmp.cpp: In function 'int compare(int)':
cmp.cpp:77:1: warning: control reaches end of non-void function [-Wreturn-type]
   77 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1968 ms 82668 KB Output is correct - maxAccess = 10, score = 100