Submission #41557

# Submission time Handle Problem Language Result Execution time Memory
41557 2018-02-18T23:27:11 Z pica4500 cmp (balkan11_cmp) C++
91 / 100
1832 ms 83948 KB
#include "cmp.h"

//91점 비벼욧---!!!
//3bit compression
int getIdx(int n, int kth) {
	n >>= (kth * 3 - 3);
	n %= 8;
	return (10000 + (kth * 8) - 7 + n);
}

void remember(int n) {
	for (int i = 4; i > 0; i--) bit_set(getIdx(n, i));
	int up = (n >> 6) + 1;
	bit_set(100 + up);
}

int compare(int b) {
	int up = (b >> 6) + 1;

	if (bit_get(100 + up)) {
		for (int i = 2; i > 0; i--) {
			int idx = getIdx(b, i);
			if (bit_get(idx)) continue;
			int c = (((idx - 10000) - 1) % 8) + 1;
			if (c < 5) {
				for (int i = c - 1; i > 0; i--)
					if (bit_get(idx - (c - i))) return 1;
				
				return -1;
			}
			else {
				for (int i = c + 1; i < 9; i++) 
					if (bit_get(idx + (i - c))) return -1;

				return 1;
			}
		}
		return 0;
	}
	else {
		for (int i = 4; i > 2; i--) {
			int idx = getIdx(b, i);
			if (bit_get(idx)) continue;
			int c = (((idx - 10000) - 1) % 8) + 1;
			if (c < 5) {
				for (int i = c - 1; i > 0; i--)
					if (bit_get(idx - (c - i))) return 1;

				return -1;
			}
			else {
				for (int i = c + 1; i < 9; i++) 
					if (bit_get(idx + (i - c))) return -1;

					return 1;
				}
		}
		return 0;
	}
	return 0;
}

Compilation message

cmp.cpp: In function 'int compare(int)':
cmp.cpp:52:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for (int i = c + 1; i < 9; i++) 
     ^~~
cmp.cpp:55:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
      return 1;
      ^~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 1832 ms 83948 KB Output is partially correct - maxAccess = 11, score = 91