# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
551 | kriii | 쉬운 문제 (GA3_easy) | C++98 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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]);
}