제출 #480784

#제출 시각아이디문제언어결과실행 시간메모리
480784minhcool비교 (balkan11_cmp)C++17
컴파일 에러
0 ms0 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

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)){
      |      ^~~~~~~