답안 #480784

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
480784 2021-10-18T04:12:33 Z minhcool 비교 (balkan11_cmp) C++17
컴파일 오류
0 ms 0 KB
#include "cmp.h"

void remember(int n) {
  //edit this
	set_bit(1 + (n & 7));
	set_bit(9 + ((n >> 3) & 7) * 8);
	set_bit(81 + ((n >> 6) & 7) * 64);
	set_bit(729 + ((n >> 9) & 7) * 512);
}

int compare(int b) {
  //edit this
  	if(!get_bit(1 + (b & 7))){
  		if((b & 7) >= 4){
  			for(int i = (b & 7) + 1; i < 8; i++){
  				if(get_bit(1 + i)){
  					return -1;
				}	
			}	
			return 1;
		}
		else{
			for(int i = 0; i < (b & 7); i++){
				if(get_bit(1 + i)){
					return 1;
				}
			}
			return -1;
		}
	}
	b >>= 3;
	if(!get_bit(9 + (b & 7) * 8)){
		if((b & 7) >= 4){
  			for(int i = (b & 7) + 1; i < 8; i++){
  				if(get_bit(9 + i * 8)){
  					return -1;
				}	
			}	
			return 1;
		}
		else{
			for(int i = 0; i < (b & 7); i++){
				if(get_bit(9 + i * 8)){
					return 1;
				}
			}
			return -1;
		}
	}
	b >>= 3;
	if(!get_bit(81 + (b & 7) * 64)){
		if((b & 7) >= 4){
  			for(int i = (b & 7) + 1; i < 8; i++){
  				if(get_bit(81 + i * 64)){
  					return -1;
				}	
			}	
			return 1;
		}
		else{
			for(int i = 0; i < (b & 7); i++){
				if(get_bit(81 + i * 64)){
					return 1;
				}
			}
			return -1;
		}
	}
	if(!get_bit(729 + (b & 7) * 512)){
		if((b & 7) >= 4){
  			for(int i = (b & 7) + 1; i < 8; i++){
  				if(get_bit(729 + i * 512)){
  					return -1;
				}	
			}	
			return 1;
		}
		else{
			for(int i = 0; i < (b & 7); i++){
				if(get_bit(729 + i * 512)){
					return 1;
				}
			}
			return -1;
		}
	}
	return 0;
}

Compilation message

cmp.cpp: In function 'void remember(int)':
cmp.cpp:5:2: error: 'set_bit' was not declared in this scope
    5 |  set_bit(1 + (n & 7));
      |  ^~~~~~~
cmp.cpp: In function 'int compare(int)':
cmp.cpp:13:8: error: 'get_bit' was not declared in this scope
   13 |    if(!get_bit(1 + (b & 7))){
      |        ^~~~~~~
cmp.cpp:32:6: error: 'get_bit' was not declared in this scope
   32 |  if(!get_bit(9 + (b & 7) * 8)){
      |      ^~~~~~~
cmp.cpp:51:6: error: 'get_bit' was not declared in this scope
   51 |  if(!get_bit(81 + (b & 7) * 64)){
      |      ^~~~~~~
cmp.cpp:69:6: error: 'get_bit' was not declared in this scope
   69 |  if(!get_bit(729 + (b & 7) * 512)){
      |      ^~~~~~~