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;
long long tot;
vector<long long> vec;
void prepare(){
tot = 1;
vec.push_back(1);
}
pair<long long, vector<long long>> join(long long p){
tot += p;
for (int i = 0; i < (int) vec.size(); ++i) {
vec[i] += p;
}
vector<long long> new_vec;
for (long long x = 1; x <= tot; ) {
new_vec.push_back(x);
if (x == tot) {
break;
}
auto next_one = upper_bound(vec.begin(), vec.end(), 2 * x) - vec.begin();
if (next_one != (int) vec.size() && vec[next_one] - p <= x * 2) {
x = x * 2;
} else {
x = vec[next_one - 1];
}
}
vec = new_vec;
vector<long long> ret = vec;
for (int i = 0; i < (int) ret.size(); ++i) {
ret[i] = tot - ret[i] + 1;
}
reverse(ret.begin(), ret.end());
return {p, ret};
}
pair<long long, vector<long long>> leave(long long p){
tot -= p;
for (int i = 0; i < (int) vec.size(); ++i) {
vec[i] -= p;
}
vector<long long> new_vec;
for (long long x = 1; x <= tot; ) {
new_vec.push_back(x);
if (x == tot) {
break;
}
auto next_one = upper_bound(vec.begin(), vec.end(), 2 * x) - vec.begin();
if (next_one != (int) vec.size() && vec[next_one] - p <= x * 2) {
x = x * 2;
} else {
x = vec[next_one - 1];
}
}
vec = new_vec;
vector<long long> ret = vec;
for (int i = 0; i < (int) ret.size(); ++i) {
ret[i] = tot - ret[i] + 1;
}
reverse(ret.begin(), ret.end());
return {p, ret};
}
# | 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... |