Submission #1095668

# Submission time Handle Problem Language Result Execution time Memory
1095668 2024-10-02T22:30:37 Z idiotcomputer cmp (balkan11_cmp) C++11
Compilation error
0 ms 0 KB
//#include "cmp.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(x) (int) (x).size()


int ch[6] = {1, 5, 22, 87, 344, 1369};
int pw[6] = {1,4,16,64,256,1024};

void remember(int value){
	int s = 0;
	for (int i = 0; i < 6; i++){
		s += pw[i] * (value%4);
		bit_set(s+ch[i]);
		value = value/4;
	}
}

int compare(int value){
	vector<int> res(6);
	vector<int> cbit(6);
	int s = 0;
	int x;
	for (int i = 0; i < 6; i++){
		s += pw[i] * (value%4);
		res[i] = s;
		cbit[i] = value%4;
		value = value/4;
	}

	int n = sz(res);
	int l = -1;
	int r = n;
	while (r-l>1){
		x = (l+r)/2;
		if (bit_get(res[x]+ch[x])) l = x;
		else r = x;
	}
	l++;
	if (l == n) return 0;
	if (cbit[l] == 0) return -1;
	if (cbit[l] == 3) return 1;
	if (cbit[l] == 1){
		x = 0;
		if (l > 0) x = res[l-1];
		if (bit_get(x+ch[l])) return 1;
		return -1;
	}
	x = 0;
	if (l > 0) x = res[l-1];
	x += pw[l]*3;
	if (bit_get(x+ch[l])) return -1;
	return 1;
}


Compilation message

cmp.cpp: In function 'void remember(int)':
cmp.cpp:15:3: error: 'bit_set' was not declared in this scope; did you mean 'tzset'?
   15 |   bit_set(s+ch[i]);
      |   ^~~~~~~
      |   tzset
cmp.cpp: In function 'int compare(int)':
cmp.cpp:37:7: error: 'bit_get' was not declared in this scope
   37 |   if (bit_get(res[x]+ch[x])) l = x;
      |       ^~~~~~~
cmp.cpp:47:7: error: 'bit_get' was not declared in this scope
   47 |   if (bit_get(x+ch[l])) return 1;
      |       ^~~~~~~
cmp.cpp:53:6: error: 'bit_get' was not declared in this scope
   53 |  if (bit_get(x+ch[l])) return -1;
      |      ^~~~~~~