Submission #41080

# Submission time Handle Problem Language Result Execution time Memory
41080 2018-02-12T13:39:17 Z hsb154 cmp (balkan11_cmp) C++14
91 / 100
1814 ms 92960 KB
#include "cmp.h"

void remember(int n) {
	int mask = 7 << 9;
	
	int me = 0;
	int shift = 9;
	for (int i = 0; mask; i++) {
		me = me * 8 + ((mask&n) >> shift)+1;
		bit_set(me);
		shift -= 3;
		mask >>= 3;
	}
}

int compare(int b) {
	
	
	int ret;
	int mask = 7 << 9;
	int shift = 9;
	int me = 0;

	for(int i=0;i<4;i++){
		
		int temp_me = me * 8 + ((mask&b) >> shift) + 1;
		if(bit_get(temp_me)==0){
			int left = me * 8 + 1;
			int right = me * 8 + 8;
			if (temp_me - left < right - temp_me) {
				for (int m = temp_me - 1; m >= left; m--) {
					if (bit_get(m) == 1)
						return 1;
				}
				return -1;
			}
			else {
				for (int m = temp_me +1; m <= right; m++) {
					if (bit_get(m) == 1)
						return -1;
				}
				return 1;
			}
		}
		me = temp_me;
		mask >>= 3;
		shift -= 3;
	}
	return 0;
}

Compilation message

cmp.cpp: In function 'int compare(int)':
cmp.cpp:19:6: warning: unused variable 'ret' [-Wunused-variable]
  int ret;
      ^~~
# Verdict Execution time Memory Grader output
1 Partially correct 1814 ms 92960 KB Output is partially correct - maxAccess = 11, score = 91