#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 time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1128 KB |
Output is correct |
2 |
Correct |
0 ms |
1128 KB |
Output is correct |
3 |
Correct |
0 ms |
1128 KB |
Output is correct |
4 |
Correct |
0 ms |
1128 KB |
Output is correct |
5 |
Correct |
0 ms |
1128 KB |
Output is correct |
6 |
Correct |
0 ms |
1128 KB |
Output is correct |
7 |
Correct |
0 ms |
1128 KB |
Output is correct |
8 |
Correct |
0 ms |
1128 KB |
Output is correct |
9 |
Correct |
0 ms |
1128 KB |
Output is correct |
10 |
Correct |
0 ms |
1128 KB |
Output is correct |
11 |
Correct |
3 ms |
1128 KB |
Output is correct |
12 |
Correct |
3 ms |
1128 KB |
Output is correct |
13 |
Correct |
9 ms |
1128 KB |
Output is correct |
14 |
Correct |
13 ms |
1128 KB |
Output is correct |
15 |
Correct |
23 ms |
1128 KB |
Output is correct |
16 |
Correct |
46 ms |
1128 KB |
Output is correct |
17 |
Correct |
66 ms |
1128 KB |
Output is correct |
18 |
Correct |
119 ms |
1128 KB |
Output is correct |
19 |
Correct |
103 ms |
1128 KB |
Output is correct |
20 |
Correct |
99 ms |
1128 KB |
Output is correct |
21 |
Correct |
116 ms |
1128 KB |
Output is correct |
22 |
Correct |
103 ms |
1128 KB |
Output is correct |