#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++) Color(remain[i]);
int cur = 1;
for(int i=0; i<rcn-2; i++){
Color(remain[0]);
for(int j=0; j<rcn-2; j++){
Color(remain[cur]); cur++;
if(cur == rcn) cur = 1;
}
}
Color(remain[0]); Color(remain[cur]);
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 |
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 |