# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
551 | kriii | 쉬운 문제 (GA3_easy) | C++98 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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]);
}