# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
551 | 2013-02-28T13:00:06 Z | kriii | 쉬운 문제 (GA3_easy) | C++ | 0 ms | 0 KB |
#include "grader.h" int B[110],end[110]; void Remark(int s, int e) { int i; for (i=s;i<e;i++) if (B[i]) Mark(i,B[i]); } void GetBestAnswer (int N, int *S, int K) { int i,j,now; for (i=0;i<N;i++) B[i] = 0, end[i] = 0; for (i=0;i<N;i+=2){ for (j=1;j<5;j++){ if (end[i] && end[i+1]) break; if (!end[i]) B[i] = j; if (!end[i+1]) B[i+1] = j; Remark(i,i+2); K--; now = GetScore(); if (S[i] != S[i+1]){ if (now == 0) continue; else if (now == S[i]) end[i] = 1; else if (now == S[i+1]) end[i+1] = 1; else end[i] = end[i+1] = 1; } else{ if (now == 0) continue; else if (now == S[i]){ if (end[i] || end[i+1]){ if ((N - i) / 2 * 5 >= K){j++; break;} continue; } B[i] = j+1; Remark(i,i+2); K--; now = GetScore(); if (now == 0){ B[i] = j; end[i] = 1; } else if (now == S[i]){ B[i+1] = j; end[i+1] = 1; j++; } else{ end[i] = end[i+1] = 1; } } else end[i] = end[i+1] = 1; } } if (!end[i]){ B[i] = j; end[i] = 1; } if (!end[i+1]){ B[i+1] = j; end[i+1] = 1; } } for (i=0;i<N;i++) Report(B[i]); }