Submission #28379

# Submission time Handle Problem Language Result Execution time Memory
28379 2017-07-16T05:06:17 Z 볼빨간 승관이(#1152, sys7961, deneb2016, hyorothy) Bulb Game (FXCUP2_bulb) C++
0 / 1
0 ms 1128 KB
#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;
    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
1 Correct 0 ms 1128 KB Output is correct
2 Correct 0 ms 1128 KB Output is correct
3 Incorrect 0 ms 1128 KB Output isn't correct
4 Halted 0 ms 0 KB -