Submission #503461

# Submission time Handle Problem Language Result Execution time Memory
503461 2022-01-08T05:06:08 Z bang627 cmp (balkan11_cmp) C++14
100 / 100
1465 ms 82496 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;
}

# Verdict Execution time Memory Grader output
1 Correct 1465 ms 82496 KB Output is correct - maxAccess = 10, score = 100