This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "light.h"
#include <bits/stdc++.h>
using namespace std;
const int LOG = 63;
int cnt;
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;
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++;
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |