Submission #1247373

#TimeUsernameProblemLanguageResultExecution timeMemory
1247373MateiKing80cmp (balkan11_cmp)C++20
100 / 100
2477 ms102332 KiB
#include "cmp.h"
#include <bits/stdc++.h>

using namespace std;

int gib(int x, int bit) {
	if (x & (1 << bit))
		return 1;
	return 0;
}

void remember(int a) {
	a += 1 << 12;
	while (a > 1) {
		bit_set(a);
		a = a / 4;
	}
}

int compare(int b) {
	b += 1 << 12;
	vector<int> nrs;
	while (b > 1) {
		nrs.push_back(b);
		b = b / 4;
	}
	int pos = -1;
	for (int pas = 16; pas; pas >>= 1)
		if (pos + pas < (int)nrs.size() && !bit_get(nrs[pos + pas]))
			pos += pas;
	if (pos == -1)
		return 0;
	b = nrs[pos];
	int x = (b / 4) * 4;
	if (b == x)
		return -1;
	if (b == x + 1)
		return bit_get(x) ? 1 : -1;
	if (b == x + 2)
		return bit_get(x + 3) ? -1 : 1;
	if (b == x + 3)
		return 1;
}

Compilation message (stderr)

cmp.cpp: In function 'int compare(int)':
cmp.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...