#include "light.h"
#include <bits/stdc++.h>
using namespace std;
const int LOG = 63;
int cnt;
bool flag;
long long sz;
vector<long long> indices;
void prepare(){
cnt = 0;
sz = 1;
indices.push_back(1);
}
int msb(long long x) {
for (int i = LOG - 1; i >= 0; --i) {
if (x >> i & 1) {
return i;
}
}
assert(false);
}
pair<long long, vector<long long>> join(long long p){
cnt++;
sz += p;
if (flag) {
indices.back() += p;
return {p, indices};
}
vector<long long> nindices = {sz};
for (long long b = 1; b < sz - 1; b *= 2) {
nindices.push_back(sz - b);
}
nindices.push_back(1);
reverse(nindices.begin(), nindices.end());
indices = nindices;
return {p, indices};
}
pair<long long, vector<long long>> leave(long long p){// I just need to make sure after one leave I'm able to keep the rightmost lit
cnt++;
flag = true;
while (indices.back() > sz - p) {
indices.pop_back();
}
sz -= p;
if (indices.back() != sz) {
indices.push_back(sz);
}
return {p, indices};
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
288 ms |
444 KB |
Correct |
3 |
Correct |
267 ms |
600 KB |
Correct |
4 |
Correct |
267 ms |
600 KB |
Correct |
5 |
Correct |
288 ms |
416 KB |
Correct |
6 |
Correct |
296 ms |
344 KB |
Correct |
7 |
Correct |
307 ms |
592 KB |
Correct |
8 |
Correct |
269 ms |
412 KB |
Correct |
9 |
Correct |
289 ms |
344 KB |
Correct |
10 |
Correct |
311 ms |
428 KB |
Correct |
11 |
Correct |
294 ms |
344 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
1 ms |
344 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
1 ms |
344 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
1 ms |
344 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
1 ms |
344 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
1 ms |
344 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
323 ms |
344 KB |
Correct |
3 |
Correct |
304 ms |
344 KB |
Correct |
4 |
Correct |
294 ms |
436 KB |
Correct |
5 |
Correct |
322 ms |
344 KB |
Correct |
6 |
Correct |
306 ms |
592 KB |
Correct |
7 |
Correct |
298 ms |
344 KB |
Correct |
8 |
Correct |
276 ms |
420 KB |
Correct |
9 |
Correct |
278 ms |
344 KB |
Correct |
10 |
Correct |
271 ms |
436 KB |
Correct |
11 |
Correct |
270 ms |
344 KB |
Correct |
12 |
Incorrect |
0 ms |
344 KB |
Not correct |
13 |
Halted |
0 ms |
0 KB |
- |