Submission #130278

# Submission time Handle Problem Language Result Execution time Memory
130278 2019-07-14T15:46:48 Z howard1005 cmp (balkan11_cmp) C++14
46 / 100
2194 ms 105080 KB
#include "cmp.h"

typedef struct _bitr{
	int min, max, idx1, idx2;
}; _bitr bitr[10240];
void remember(int n) {
	int ntmp = n;
	int bi[12] = { 0, };
	int i = 0, sum = 0;
	while (ntmp){
		if (ntmp % 2){
			bi[i] = 1;
			sum++;
		}
		i++;
		ntmp /= 2;
	}
	int bi_rev[12];
	for (int a = 0; a < 12; a++) bi_rev[a] = bi[11 - a];
	int idx = 1;
	for (int a = 0; a < 12; a++){
		if (bi_rev[a]){
			idx = 2 * idx + 1;
			bit_set(idx);
		}
		else{
			idx = 2 * idx;
			bit_set(idx);
		}
	}
}
int compare(int b) {
	int l = 1, r = 12, m, c, same = 0;
	while (l <= r){
		m = (l + r) / 2;
		c = (b >> (12 - m)) | (1 << m);
		if (bit_get(c)){
			same = m;
			l = m + 1;
		}
		else{
			r = m - 1;
		}
	}
	if (same == 12) return 0;
	else if ((b >> (11 - same)) & 1) return 1;
	else return -1;
}

Compilation message

cmp.cpp:3:1: warning: 'typedef' was ignored in this declaration
 typedef struct _bitr{
 ^~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 2194 ms 105080 KB Output is partially correct - maxAccess = 16, score = 46