Submission #480790

# Submission time Handle Problem Language Result Execution time Memory
480790 2021-10-18T04:18:42 Z minhcool cmp (balkan11_cmp) C++17
91 / 100
2045 ms 92436 KB
#include "cmp.h"
 
#define set_bit bit_set
#define get_bit bit_get
 
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
  int temp = ((b >> 9) & 7);
  	if(!get_bit(729 + temp * 512)){
		if(temp >= 4){
  			for(int i = temp + 1; i < 8; i++){
  				if(get_bit(729 + i * 512)){
  					return -1;
				}	
			}	
			return 1;
		}
		else{
			for(int i = 0; i < temp; i++){
				if(get_bit(729 + i * 512)){
					return 1;
				}
			}
			return -1;
		}
	}
  temp = ((b >> 6) & 7);
  if(!get_bit(81 + temp * 64)){
		if(temp >= 4){
  			for(int i = temp + 1; i < 8; i++){
  				if(get_bit(81 + i * 64)){
  					return -1;
				}	
			}	
			return 1;
		}
		else{
			for(int i = 0; i < temp; i++){
				if(get_bit(81 + i * 64)){
					return 1;
				}
			}
			return -1;
		}
	}
  temp = ((b >> 3) & 7);
    if(!get_bit(9 + temp * 8)){
		if(temp >= 4){
  			for(int i = temp + 1; i < 8; i++){
  				if(get_bit(9 + i * 8)){
  					return -1;
				}	
			}	
			return 1;
		}
		else{
			for(int i = 0; i < temp; i++){
				if(get_bit(9 + i * 8)){
					return 1;
				}
			}
			return -1;
		}
	}
  	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;
		}
	}
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Partially correct 2045 ms 92436 KB Output is partially correct - maxAccess = 11, score = 91