Submission #28501

#TimeUsernameProblemLanguageResultExecution timeMemory
28501일단아무거나적어놓은팀이름 (#68)Bulb Game (FXCUP2_bulb)C++14
1 / 1
119 ms1128 KiB
#include "bulb.h"
int n;
bool b[1010], used[1010];
void Init(int N) {
    n = N;
    for(int i = 1; i <= n - 1; ++i) b[i] = 0;
    for(int i = 1; i <= n; ++i) used[i] = 0;
}
int MakeTurn(int M) {
    used[M] = 1;
    int cnt = 0, mx = -1, sel = -1;
    for(int i = 1; i <= n - 1; ++i)
        if(b[i]) cnt++;
    for(int i = 1; i <= n; ++i) {
        if(used[i]) continue;
        int l = i < M ? i : M;
        int r = i > M ? i : M;
        int loc = cnt;
        for(int j = l; j < r; ++j) {
            if(b[j]) loc--;
            else loc++;
        }
        if(mx < loc) mx = loc, sel = i;
    }
    int l = sel < M ? sel : M;
    int r = sel > M ? sel : M;
    for(int i = l; i < r; ++i) b[i] = 1 - b[i];
    used[sel] = 1;
    return sel;
}
#Verdict Execution timeMemoryGrader output
Fetching results...