답안 #57714

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
57714 2018-07-15T21:51:54 Z SpeedOfMagic 비교 (balkan11_cmp) C++17
0 / 100
2613 ms 125952 KB
#include "cmp.h"
#include <bits/stdc++.h>
using namespace std;

void remember(int a) {
	bit_set(a + 100);
	
	int oneAmount = 0;
	for (int i = 0; i < 12; i++)
		if (a & (1 << i))
			oneAmount++;
	
	if (oneAmount > 6) {
		bit_set(13);
		a = -a;
	}
	
	for (int i = 0; i < 12; i++)
		if ((1 << i) & a)
			bit_set(i + 1);
}

int compare(int b) {
	srand(time(0));
	
	int k = bit_get(100 + b);
	if (k)
		return 0;
	
	int d = bit_get(13);
	
	int pos[12];
	for (int i = 0; i < 12; i++)
		pos[i] = -1;
	
	int l = 0, r = 11;
	while (1) {
		bool empt = all_of(pos + l, pos + r + 1, [](int z){return z != -1;});
		if (empt)
			break;
		
		vector<int> forRand;
		for (int i = l + 1; i < r; i++)
			if (pos[i] == -1)
				forRand.push_back(i);
			
		int m = forRand[rand() % forRand.size()];
		
		int p = bit_get(m + 1);
		pos[m] = p;
		if (((1 << m) & b) != pos[m])
			l = m;
	}
	
	
	int a = 1 << l;
	
	if ((a < b && !d) || (a > b && d))
		return 1;
	else
		return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2613 ms 125952 KB Execution killed with signal 8 (could be triggered by violating memory limits)