Submission #420078

# Submission time Handle Problem Language Result Execution time Memory
420078 2021-06-08T05:16:17 Z maximath_1 cmp (balkan11_cmp) C++11
100 / 100
2068 ms 102172 KB
#include "cmp.h"
using namespace std;

int cnt = 0;

void remember(int n){
	n += 4096;
	for(; n > 1; n >>= 2, cnt ++)
		bit_set(n);
}

int compare(int a){
	a += 4096;

	int lf = 0, rg = 6, gt = -1;
	for(int md; lf <= rg;){
		md = (lf + rg) >> 1;
		if(md != 6 && !bit_get(a >> (md * 2))){
			gt = a >> (md * 2);
			lf = md + 1;
		}else rg = md - 1;
	}

	if(gt == -1) return 0;

	if(gt % 4 == 0) return -1;
	else if(gt % 4 == 1) return bit_get(gt / 4 * 4) ? 1 : -1;
	else if(gt % 4 == 2) return bit_get(gt / 4 * 4 + 3) ? -1 : 1;
	else return 1;

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2068 ms 102172 KB Output is correct - maxAccess = 10, score = 100