답안 #28376

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28376 2017-07-16T05:05:49 Z 점수판에 아이디와 팀명이 같이 표기되니, 신중하게 적어주세요.(#1186, kajebiii, secsegy, woqja125) 1-Color Coloring (FXCUP2_coloring) C++
1 / 1
0 ms 1124 KB
#include "coloring.h"
#include<algorithm>
#include<stdlib.h>

int next[101];
int prev[101];
int chk[101];
int n;

int list[101];
void swap(int &a, int &b) { a ^= b ^= a ^= b; }
int findprev(int x, int *l, int n) {
	int f=1, r=n;
	while (f<r) {
		int m = (f + r + 1) / 2;
		for (int i = f; i < m; i++) Color(l[i]);
		if(GetColor(x) == 0) r = m - 1;
		else f = m;
	}
	return l[f];
}

void ColoringSame(int N){
	n = N;
	int x = 1;
	chk[1] = 1;
	for (int i = 1; i < n; i++) list[i] = i+1;
	int s = n-1;
	for (int i = 1; i <= 28 && i < n; i++) {
		prev[x] = findprev(x, list, s);
		next[prev[x]] = x;
		x = prev[x];
		chk[x] = 1;
		int j;
		for (j = 1; list[j] != x; j++);
		for (; j < s; j++) list[j] = list[j + 1];
		s--;
	}
	Color(1);
	srand(13082);
	for (int i = 1; i < s; i++) {
		swap(list[i], list[rand() % (s - i) + i + 1]);
	}
	for (int i = 1; i <= N-28 && i <= 67; i++) {
		for (int j = 1; j <= s; j++) {
			Color(list[j]);
		}
	}
	while (x != 1) {
		Color(x);
		x = next[x];
	}
}
# 결과 실행 시간 메모리 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 Correct 0 ms 1124 KB Output is correct
17 Correct 0 ms 1124 KB Output is correct
18 Correct 0 ms 1124 KB Output is correct
19 Correct 0 ms 1124 KB Output is correct
20 Correct 0 ms 1124 KB Output is correct
21 Correct 0 ms 1124 KB Output is correct
22 Correct 0 ms 1124 KB Output is correct
23 Correct 0 ms 1124 KB Output is correct
24 Correct 0 ms 1124 KB Output is correct
25 Correct 0 ms 1124 KB Output is correct