답안 #163958

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
163958 2019-11-16T12:14:36 Z rolypolyvg295 비교 (balkan11_cmp) C++14
100 / 100
1904 ms 99004 KB
#include "cmp.h"
#include <iostream>
using namespace std;

void remember(int n) {
	int a = n >> 9;
	int b = (n >> 6) & ((1<<3)-1);
	int c = (n >> 3) & ((1<<3)-1);
	int d = n & ((1<<3)-1);

	bit_set(d + 1);
	bit_set(c + 1 + (1<<3));
	bit_set((a<<3) + b + 1 + (1<<6));
	bit_set(a + 1 + (1<<12));
}

int check_triple(int n, int offset, int extra){
	if (n >= 4){
		for (int i = 7; i > n; i--)
			if (bit_get(i + offset + extra))
				return -1;

		return 1;
	}else{
		for (int i = 0; i < n; i++)
			if (bit_get(i + offset + extra))
				return 1;

		return -1;
	}
}

int compare(int n) {
	int a = n >> 9;
	int b = (n >> 6) & ((1<<3)-1);
	int c = (n >> 3) & ((1<<3)-1);
	int d = n & ((1<<3)-1);

	if (bit_get((a<<3) + b + 1 + (1<<6))){
		if (bit_get(c + 1 + (1<<3))){
			if (bit_get(d + 1)){
				return 0;
			}else{
				return check_triple(d, 0, 1);
			}
		}else{
			return check_triple(c, 0, 1 + (1<<3));
		}
	}else{
		if (bit_get(a + 1 + (1<<12))){
			return check_triple(b, a<<3, 1 + (1<<6));
		}else{
			return check_triple(a, 0, 1 + (1<<12));
		}
	}
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1904 ms 99004 KB Output is correct - maxAccess = 10, score = 100