Submission #108074

# Submission time Handle Problem Language Result Execution time Memory
108074 2019-04-27T07:08:19 Z Diuven cmp (balkan11_cmp) C++14
100 / 100
2498 ms 82552 KB
#include "cmp.h"

const int P[4] = {12, 10, 8, 6}, tot = 12*10*8*6;

void remember(int n) {
	int base = 1, now = tot;
	for(int i=0, p, x; i<4; i++){
		p = P[i], now /= p, x = n/now;
		bit_set(base + x);
		base += p, n %= now;
	}
}

int compare(int m) {
	int base = 1, now = tot;
	for(int i=0, p, x; i<4; i++){
		p = P[i], now /= p, x = m/now;
		if(bit_get(base+x)){
			base += p, m %= now;
		}
		else if(x<p/2){
			for(int j=x-1; j>=0; j--)
				if(bit_get(base+j)) return 1;
			return -1;
		}
		else {
			for(int j=x+1; j<p; j++)
				if(bit_get(base+j)) return -1;
			return 1;
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2498 ms 82552 KB Output is correct - maxAccess = 10, score = 100