Submission #24168

# Submission time Handle Problem Language Result Execution time Memory
24168 2017-06-01T06:55:50 Z yys11631 cmp (balkan11_cmp) C++14
100 / 100
2099 ms 83704 KB
#include "cmp.h"
#include<algorithm>

using namespace std;
void remember(int n) {
	static int d[5],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 a[5], 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:6:18: warning: unused variable 'l' [-Wunused-variable]
  static int d[5],l=0,i;
                  ^
cmp.cpp:6:22: warning: unused variable 'i' [-Wunused-variable]
  static int d[5],l=0,i;
                      ^
cmp.cpp: In function 'int compare(int)':
cmp.cpp:22:19: warning: unused variable 'l' [-Wunused-variable]
  static int a[5], l = 0, i;
                   ^
cmp.cpp: At global scope:
cmp.cpp:22:19: warning: 'l' defined but not used [-Wunused-variable]
cmp.cpp:6:22: warning: 'i' defined but not used [-Wunused-variable]
  static int d[5],l=0,i;
                      ^
cmp.cpp:6:18: warning: 'l' defined but not used [-Wunused-variable]
  static int d[5],l=0,i;
                  ^
# Verdict Execution time Memory Grader output
1 Correct 2099 ms 83704 KB Output is correct - maxAccess = 10, score = 100