Submission #1247366

#TimeUsernameProblemLanguageResultExecution timeMemory
1247366MateiKing80cmp (balkan11_cmp)C++20
0 / 100
599 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;
}

const int bulan = 4096;

void remember(int a) {
	a += bulan;
	while (a) {
		bit_set(a);
		a = (a - 1) / 4;
	}
}

int compare(int b) {
	b += bulan;
	vector<int> nrs;
	while (b) {
		nrs.push_back(b);
		b = (b - 1) / 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 - 1) / 4) * 4 + 1;
	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:45:1: warning: control reaches end of non-void function [-Wreturn-type]
   45 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...