답안 #503462

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
503462 2022-01-08T05:11:34 Z bang627 비교 (balkan11_cmp) C++14
100 / 100
1210 ms 82488 KB
#include "cmp.h"
#include <iostream>

using namespace std;

void remember(int a) {
	bit_set(1 + (int)a / (10 * 8 * 6));
	a %= 10 * 8 * 6;
	bit_set(1+10 + (int)a / (8 * 6));
	a %= 8 * 6;
	bit_set(1+10+ 10 + (int)a / 6);
	a %= 6;
	bit_set(1+10+ 10 +8+a);
}

int compare(int b) {

	int readed,val;
	readed =bit_get(1 + (int)b / (10 * 8 * 6)), val = (int)b / (10 * 8 * 6);
	//cout << endl;
	//cout << val << " ";
	if (readed == 0) {
		if (val <= 4) {
			for (int j = 0; j < val; j++) if (bit_get(1 + j) == 1) return 1;
			return -1;
		}
		else {
			for (int j = 8; j > val; j--) if (bit_get(1 + j) == 1) return -1;
			return 1;
		}
	}
	b %= 10 * 8 * 6;
	readed= bit_get(1+10 + (int)b / (8 * 6)), val = (int)b/(8*6);
	//cout << val << " ";
	if (readed == 0) {
		if (val <= 4) {
			for (int j = 0; j < val; j++) if (bit_get(1 + 10 + j) == 1) return 1;
			return -1;
		}
		else {
			for (int j = 9; j > val; j--) if (bit_get(1 + 10  + j) == 1) return -1;
			return 1;
		}
	}
	b %= 8 * 6;
	readed= bit_get(1+10+10+(int)b / 6), val = (int)b /  6;
	//cout << val << " ";
	if (readed == 0) {
		if (val <= 3) {
			for (int j = 0; j < val; j++) if (bit_get(1 + 10 + 10+j) == 1) return 1;
			return -1;
		}
		else {
			for (int j = 7; j > val; j--) if (bit_get(1 + 10 + 10  + j) == 1) {
		//		cout << "hi";
				return -1;
			}
			return 1;
		}
	}
	b %= 6;
	readed= bit_get(1+10+10+8+ b), val = b;
	//cout << val << " " << endl;
	if (readed == 0) {
		if (val <= 2) {
			for (int j = 0; j < val; j++) if (bit_get(1 + 10 + 10+8+ j) == 1) return 1;
			return -1;
		}
		else {
			for (int j = 5; j > val; j--) if (bit_get(1 + 10 + 10 + 8 + j) == 1) return -1;
			return 1;
		}
	}
	return 0;
}

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