답안 #27262

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
27262 2017-07-12T03:13:55 Z 검수컵(#1129) 1-Color Coloring (FXCUP2_coloring) C++
0 / 1
0 ms 1124 KB
#include "coloring.h"

int N, chk[101], remain[101];
int pvcn = 28, prevs[101];

int get_prv(int ix){
	int rcn=0;
	for(int i=1; i<=N; i++){
		if(!chk[i]) remain[rcn++] = i;
	}
	int mi=0, mx=rcn-1, md;
	while(1){
		md = (mi+mx-1)/2;
		if(mi >= mx){ md = mi; break; }
		for(int i=mi; i<=md; i++) Color(remain[i]);
		if(!GetColor(ix)) mx = md;
		else mi = md+1;
	}
	return remain[md];
}

void ColoringSame(int N_){
	N = N_;

	int pv = 1; chk[1] = 1;
	for(int i=0; i<pvcn; i++){
		prevs[i] = pv = get_prv(pv), chk[pv] = 1;
		if(i == N-2){
			Color(1);
			for(int k=N-2; k>=0; k--) Color(prevs[k]);
			return;
		}
	}

	int rcn=0;
	for(int i=1; i<=N; i++){
		if(!chk[i]) remain[rcn++] = i;
	}
	Color(1);
	for(int i=0; i<rcn; i++){
		for(int j=0; j<rcn; j++) Color(remain[j]);
	}

	for(int i=pvcn-1; i>0; i--) Color(prevs[i]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1124 KB Output is correct
2 Correct 0 ms 1124 KB Output is correct
3 Correct 0 ms 1124 KB Output is correct
4 Correct 0 ms 1124 KB Output is correct
5 Correct 0 ms 1124 KB Output is correct
6 Correct 0 ms 1124 KB Output is correct
7 Correct 0 ms 1124 KB Output is correct
8 Correct 0 ms 1124 KB Output is correct
9 Correct 0 ms 1124 KB Output is correct
10 Correct 0 ms 1124 KB Output is correct
11 Correct 0 ms 1124 KB Output is correct
12 Correct 0 ms 1124 KB Output is correct
13 Correct 0 ms 1124 KB Output is correct
14 Correct 0 ms 1124 KB Output is correct
15 Correct 0 ms 1124 KB Output is correct
16 Incorrect 0 ms 1124 KB Output isn't correct
17 Halted 0 ms 0 KB -