# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
28382 | 볼빨간 승관이 (#68) | Bulb Game (FXCUP2_bulb) | C++98 | 3 ms | 1128 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <cstring>
#include <algorithm>
bool haha[1005], check[1005];
int Num;
void Init(int N)
{
memset(check, 0, sizeof(check));
memset(haha, 0, sizeof(haha));
Num = N;
}
int MakeTurn(int M)
{
int flag = 0;
int tcnt = 0, fcnt = 0, maxidx = 0, maxv = -987654321;
check[M] = true;
for(int i = M; i < Num; ++i) {
if(haha[i])
tcnt++;
else
fcnt++;
if(!check[i + 1] && maxv < fcnt - tcnt) {
maxv = fcnt - tcnt;
maxidx = i;
flag = 1;
}
}
tcnt = 0, fcnt = 0;
for(int i = M - 1; i >= 1; --i) {
if(haha[i])
tcnt++;
else
fcnt++;
if(!check[i] && maxv < fcnt - tcnt) {
maxv = fcnt - tcnt;
maxidx = i;
flag = -1;
}
}
if(flag > 0) {
for(int i = M; i <= maxidx; ++i) {
haha[i] = !haha[i];
}
check[maxidx + 1] = true;
return maxidx + 1;
}
else {
for(int i = maxidx; i < M; ++i) {
haha[i] = !haha[i];
}
check[maxidx] = true;
return maxidx;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |