#include "coloring.h"
int next[101];
int prev[101];
int chk[101];
int n;
int findprev(int x) {
int f=1, r=n;
while (f<r) {
int m = (f + r + 1) / 2;
for (int i = f; i < m; i++) Color(i);
if(GetColor(x) == 0) r = m - 1;
else f = m;
}
return f;
}
void ColoringSame(int N){
n = N;
int x = 1;
chk[1] = 1;
for (int i = 1; i <= 28 && i < n; i++) {
prev[x] = findprev(x);
next[prev[x]] = x;
x = prev[x];
chk[x] = 1;
}
Color(1);
for (int i = 1; i <= N-28; i++) {
for (int j = 1; j <= N; j++) {
if (!chk[j]) Color(j);
}
}
while (x != 1) {
Color(x);
x = next[x];
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1124 KB |
Output is correct |
2 |
Incorrect |
0 ms |
1124 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |