#include "light.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvl = vector<vll>;
using pll = pair<ll,ll>;
using vpl = vector<pll>;
using vvp = vector<vpl>;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(),v.end()
vll pl;
ll n=1;
void prepare(){
pl = {1};
}
void solve(ll w, ll p){
vll ans={1};
while(ans.back()<n){
ll t = ans.back();
ll x = lower_bound(all(pl), t*2+1-w)-pl.begin();
if(x<pl.size()){
if(pl[x]+w-p<=t*2+1){
ans.pb(t*2+1);
continue;
}
}
if(x>0){
ans.pb(pl[x-1]+w);
}
}
pl=ans;
}
vll rev(){
vll ans;
for(ll i = pl.size()-1; i>= 0; --i)ans.pb(n+1-pl[i]);
return ans;
}
pair<ll, vll> join(ll p){
n+=p;
solve(p, p);
return {p, rev()};
}
pair<ll, vll> leave(ll p){
n-=p;
solve(-p, p);
return {p, rev()};
}
# | 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... |