Submission #381040

# Submission time Handle Problem Language Result Execution time Memory
381040 2021-03-24T10:10:08 Z wp1270 cmp (balkan11_cmp) C++14
82 / 100
1965 ms 82668 KB
#include "cmp.h"


void remember(int n) {
	int first = n / 64;
	int second = n % 64;
	bit_set(first / 10 + 1);
	bit_set(first % 10 + 8);
	bit_set(second / 10 + 19);
	bit_set(second % 10 + 26);
}

int compare(int b) {
	int first_b = b / 64;
	int second_b = b % 64;
	int m_f = first_b / 10;
	if (bit_get(m_f + 1)) {
		int k_f = first_b % 10;
		if (bit_get(k_f + 8)) {
			int m_s = second_b / 10;
			if (bit_get(m_s + 19)) {
				int k_s = second_b % 10;
				if (bit_get(k_s + 26)) {
					return 0;
				}
				else if (k_s >= 5) {
					for (int i = k_s + 1; i <= 9; i++) {
						if (bit_get(i + 26)) return -1;
					}
					return 1;
				}
				else if (k_s < 5) {
					for (int i = k_s - 1; i >= 0; i--) {
						if (bit_get(i + 26)) return 1;
					}
					return -1;
				}
			}
			else if (m_s >= 4) {
				for (int i = m_s + 1; i <= 6; i++) {
					if (bit_get(i + 19)) return -1;
				}
				return 1;
			}
			else if (m_s < 4) {
				for (int i = m_s - 1; i >= 0; i--) {
					if (bit_get(i + 19)) return 1;
				}
				return -1;
			}
		}
		else if (k_f >= 5) {
			for (int i = k_f + 1; i <= 9; i++) {
				if (bit_get(i + 8)) return -1;
			}
			return 1;
		}
		else if (k_f < 5) {
			for (int i = k_f - 1; i >= 0; i--) {
				if (bit_get(i + 8)) return 1;
			}
			return -1;
		}
	}
	else if (m_f >= 4) {
		for (int i = m_f + 1; i <= 6; i++) {
			if (bit_get(i + 1)) return -1;
		}
		return 1;
	}
	else if (m_f < 4) {
		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 | }
      | ^
# Verdict Execution time Memory Grader output
1 Partially correct 1965 ms 82668 KB Output is partially correct - maxAccess = 12, score = 82