#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define fr first
#define sc second
#define endl '\n'
using namespace std;
#define mid ((left+right)>>1)
#include "light.h"
ll n=1;
vector<ll>v;
void prepare(){
v.pb(1);
}
void f(ll p){
vector<pair<ll,ll>>sta;
for(int i=0;i<v.size();i++){
sta.pb({v[i],min(v[i]+p,n)});
}
v.clear();
ll las=n;
v.pb(n);
while(sta.size()){
pair<ll,ll>x=sta.back();
sta.pop_back();
if(x.sc>=las)x.sc=las-1;
if(x.fr>x.sc)continue;
ll m=n-las+1;
while(x.fr<=las-m-1){
las=las-m-1;
m=n-las+1;
v.pb(las);
x.sc=las-1;
if(x.fr>x.sc)break;
}
if(x.fr>x.sc)continue;
if(!sta.size()||sta.back().sc<las-m-1){
las=x.fr;
v.pb(las);
}
}
reverse(v.begin(),v.end());
}
pair<ll,vector<ll>> join(ll p){
n+=p;
f(p);
return {p,v};
}
pair<ll,vector<ll>> leave(ll p){
n-=p;
while(v.back()>n){
v.pop_back();
}
f(p);
return {p,v};
}
| # | 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... |