답안 #106935

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
106935 2019-04-21T09:22:33 Z yys11631 비교 (balkan11_cmp) C++17
100 / 100
2235 ms 83668 KB
#include "cmp.h"
#include<algorithm>
 
int d[5];
int a[5];
using namespace std;
void remember(int n) {
	static int l=0,i;
	d[0] = n % 6;
	n /= 6;
	d[1] = n % 8;
	n /= 8;
	d[2] = n % 10;
	n /= 10;
	d[3] = n % 12;
	n /= 12;
	bit_set(100+d[3]);
	bit_set(200+d[2]);
	bit_set(300 + d[1]);
	bit_set(400 + d[0]);
}
 
int compare(int b) {
	static int l = 0, i;
	a[0] = b % 6;
	b /= 6;
	a[1] = b % 8;
	b /= 8;
	a[2] = b % 10;
	b /= 10;
	a[3] = b % 12;
	b /= 12;
	if (!bit_get(a[3] + 100)) {
		if (a[3] >= 6) {
			for (i = a[3] + 1; i < 12; i++) {
				if (bit_get(i+100))
					return -1;
			}
			return 1;
		}
		else {
			for (i = a[3] - 1; i >= 0; i--) {
				if (bit_get(i+100))
					return 1;
			}
			return -1;
		}
	}
	else if (!bit_get(a[2] + 200)) {
		if (a[2]>= 5) {
			for (i = a[2]+1; i < 10; i++) {
				if (bit_get(i+200))
					return -1;
			}
			return 1;
		}
		else {
			for (i = a[2] - 1; i >= 0; i--) {
				if (bit_get(i+200))
					return 1;
			}
			return -1;
		}
	}
	else if (!bit_get(a[1] + 300)) {
		if (a[1]>= 4) {
			for (i = a[1] + 1; i < 8; i++) {
				if (bit_get(i+300))
					return -1;
			}
			return 1;
		}
		else {
			for (i = a[1] - 1; i >= 0; i--) {
				if (bit_get(i+300))
					return 1;
			}
			return -1;
		}
	}
	else if (!bit_get(a[0] + 400)) {
		if (a[0] >= 3) {
			for (i = a[0] + 1; i <6; i++) {
				if (bit_get(i+400))
					return -1;
			}
			return 1;
		}
		else {
			for (i = a[0] - 1; i >= 0; i--) {
				if (bit_get(i+400))
					return 1;
			}
			return -1;
		}
	}
	return 0;
}

Compilation message

cmp.cpp: In function 'void remember(int)':
cmp.cpp:8:13: warning: unused variable 'l' [-Wunused-variable]
  static int l=0,i;
             ^
cmp.cpp:8:17: warning: unused variable 'i' [-Wunused-variable]
  static int l=0,i;
                 ^
cmp.cpp: In function 'int compare(int)':
cmp.cpp:24:13: warning: unused variable 'l' [-Wunused-variable]
  static int l = 0, i;
             ^
cmp.cpp: At global scope:
cmp.cpp:24:13: warning: 'l' defined but not used [-Wunused-variable]
cmp.cpp:8:17: warning: 'i' defined but not used [-Wunused-variable]
  static int l=0,i;
                 ^
cmp.cpp:8:13: warning: 'l' defined but not used [-Wunused-variable]
  static int l=0,i;
             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2235 ms 83668 KB Output is correct - maxAccess = 10, score = 100