답안 #44785

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
44785 2018-04-06T11:38:19 Z tjd229 질문 (CEOI14_question_grader) C++11
100 / 100
1667 ms 78800 KB
int digit12[924];
void n2digit12(){
	int i1, i2, i3, i4, i5, i6;
	int ix = 0;
	for (i1 = 0; i1 < 12; i1++){
		for (i2 = i1 + 1; i2 < 12; i2++){
			for (i3 = i2 + 1; i3 < 12; i3++){
				for (i4 = i3 + 1; i4 < 12; i4++){
					for (i5 = i4 + 1; i5 < 12; i5++){
						for (i6 = i5 + 1; i6 < 12; i6++){
							digit12[ix++] = (1 << i1) + (1 << i2) + (1 << i3)
								+ (1 << i4) + (1 << i5) + (1 << i6);
						}
					}
				}
			}
		}
	}
}
int encode(int n, int x, int y) {
	static bool flag = true;
	if (flag) n2digit12(), flag = false;
	int bit = 1;
	for (int i = 0; i < 12; i++,bit<<=1){
		if ((digit12[x] & bit) && !(digit12[y] & bit))
			return i + 1;
	}
	return 0;
}

int digit12[924];

void n2digit12(){
	int i1, i2, i3, i4, i5, i6;
	int ix = 0;
	for (i1 = 0; i1 < 12; i1++){
		for (i2 = i1 + 1; i2 < 12; i2++){
			for (i3 = i2 + 1; i3 < 12; i3++){
				for (i4 = i3 + 1; i4 < 12; i4++){
					for (i5 = i4 + 1; i5 < 12; i5++){
						for (i6 = i5 + 1; i6 < 12; i6++){
							digit12[ix++] = (1 << i1) + (1 << i2) + (1 << i3)
								+ (1 << i4) + (1 << i5) + (1 << i6);
						}
					}
				}
			}
		}
	}
}

int decode(int n, int q, int h) {
	static int flag = true;
	if (flag) n2digit12(),flag=false;
	int bit = 1 << (h - 1);
	return (digit12[q] & bit) != 0;	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1667 ms 78800 KB Output is correct - maxh = 12
2 Correct 1641 ms 78800 KB Output is correct - maxh = 12