Submission #28666

#TimeUsernameProblemLanguageResultExecution timeMemory
28666쥬니님일어나세요 버스운전해주시기로했잖아요 (#68)1-Color Coloring (FXCUP2_coloring)C++11
1 / 1
0 ms1124 KiB
#include "coloring.h" #include <cstdio> int next[111]; int n; int k; int ccolor = 0; int cgetcolor = 0; void ColorX(int x) { //printf("Color %d\n", x); ccolor++; return Color(x); } int GetColorX(int x) { cgetcolor++; //printf("GetColor %d\n", x); return GetColor(x); } int find_prev(int x) { //printf("find_prev %d\n", x); int rem = n - k - 1; if (rem == 0) { return 1; } int mn = 1; int mx = n; while(1) { if (rem == 1) break; int i; int c = rem / 2; int cc = c; for(i = mn;;i++) { if (next[i] == -1 && i != x) { ColorX(i); c--; if (c == 0) { break; } } } int exist = GetColorX(x); if (exist) { mn = i+1; rem = rem - cc; } else { mx = i; rem = cc; } } for (int i = mn; i <= mx; i++) { if (next[i] == -1 && i != x) { return i; } } return 0; } void ColoringSame(int N) { n = N; k = 0; for(int i=1;i<=N;i++){ next[i] = -1; } next[1] = 0; int pr; int nx = 1; int A = 0; int last; for(int i=0;;i++){ pr = find_prev(nx); A++; last = pr; next[pr] = nx; //printf("%d -> %d\n", pr, nx); k++; nx = pr; if (nx == 1)break; if (cgetcolor >=194)break; } //printf("Color: %d\nGetColor: %d\n", ccolor, cgetcolor); ColorX(1); for (int i=0;i<n - A - 1;i++){ for(int j=1;j<=n;j++) { if (next[j] == -1) { ColorX(j); if (ccolor == 7250)break; } } if (ccolor == 7250)break; } for(;;) { if (next[last] == 1) break; ColorX(last); last = next[last]; } //printf("Color: %d\nGetColor: %d\n", ccolor, cgetcolor); }
#Verdict Execution timeMemoryGrader output
Fetching results...