#include "light.h"
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll n;
vector<ll> V,R;
void prepare(){
n=1;
V.push_back(1);
}
std::pair<ll, std::vector<ll>> join(ll p){
n+=p;
vector<ll> NV=V;
NV.push_back(n);
V.clear();
V.push_back(NV[0]);
V.push_back(NV[1]);
for(int i=2;i<(int)NV.size();i++){
if(i+1<(int)NV.size()&&NV[i+1]<=V.back()+V.end()[-2]) continue;
V.push_back(NV[i]);
}
R=V;
for(ll &x: R) x=n+1-x;
reverse(R.begin(),R.end());
return {p,R};
}
std::pair<ll, std::vector<ll>> leave(ll p){
n-=p;
if(n==1){
V=R={1};
return {0,R};
}
reverse(V.begin(),V.end());
while(V.back()<=p) V.pop_back();
for(ll &x: V) x-=p;
V.push_back(1);
reverse(V.begin(),V.end());
vector<ll> NV=V;
V.clear();
V.push_back(NV[0]);
V.push_back(NV[1]);
for(int i=2;i<(int)NV.size();i++){
if(i+1<(int)NV.size()&&NV[i+1]<=V.back()+V.end()[-2]) continue;
V.push_back(NV[i]);
}
R=V;
for(ll &x: R) x=n+1-x;
reverse(R.begin(),R.end());
return {p,R};
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
0 ms |
344 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
0 ms |
344 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
0 ms |
344 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
0 ms |
344 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
0 ms |
344 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
0 ms |
344 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Incorrect |
1 ms |
344 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |