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>
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
using namespace std;
ll n, maxi;
vector<ll> prevs;
void prepare(){
n = 1;
maxi = n;
prevs = {1};
}
pair<long long, std::vector<long long>> join(long long p){
n += p;
set<ll> stuff;
stuff.insert(1);
stuff.insert(n);
for (auto&i : prevs){
if (i != 1) stuff.insert(i+p);
}
vector<ll> real;
for (auto&i : stuff) if (1<=i && i<=n) real.push_back(i);
vector<ll> spare;
FORNEG(i, real.size()-1, 0){
//cout << (n-real[i] + 1) << " " << (real[i] - real[i-1] - 1) << endl;
while ((n-real[i] + 1) < (real[i] - real[i-1] - 1)){
spare.push_back(real[i]);
real[i] = n - (n-real[i] + 1)*2;
}
}
for (auto&i : spare) real.push_back(i);
sort(real.begin(), real.end());
vector<ll> realreal;
for (auto&i : real){
while (realreal.size() >= 2 && ((n-i + 1) >= (i - realreal[realreal.size()-2] - 1))){
realreal.pop_back();
}
realreal.push_back(i);
}
prevs = realreal;
return {p,realreal};
}
std::pair<long long, std::vector<long long>> leave(long long p){
n -= p;
set<ll> stuff;
stuff.insert(1);
stuff.insert(n);
for (auto&i : prevs){
if (i != 1) stuff.insert(i);
}
vector<ll> real;
for (auto&i : stuff) if (1<=i && i<=n) real.push_back(i);
vector<ll> spare;
FORNEG(i, real.size()-1, 0){
//cout << (n-real[i] + 1) << " " << (real[i] - real[i-1] - 1) << endl;
while ((n-real[i] + 1) < (real[i] - real[i-1] - 1)){
spare.push_back(real[i]);
real[i] = n - (n-real[i] + 1)*2;
}
}
for (auto&i : spare) real.push_back(i);
sort(real.begin(), real.end());
vector<ll> realreal;
for (auto&i : real){
while (realreal.size() >= 2 && ((n-i + 1) >= (i - realreal[realreal.size()-2] - 1))){
realreal.pop_back();
}
realreal.push_back(i);
}
prevs = realreal;
return {p,realreal};
}
# | 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... |