#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(1);
NV.push_back(2);
NV.push_back(n-1);
NV.push_back(n);
sort(NV.begin(),NV.end());
NV.resize(unique(NV.begin(),NV.end())-NV.begin());
V.clear();
V.push_back(NV[0]);
V.push_back(NV[1]);
for(int i=2;i<(int)NV.size();i++){
while(NV[i]>V.end()[-1]+(V.end()[-2]+1)/2){
V.push_back(V.end()[-1]+(V.end()[-2]+1)/2);
}
if(i+1<(int)NV.size()&&NV[i+1]<=V.end()[-1]+(V.end()[-2]+1)/2) continue;
V.push_back(NV[i]);
}
R=V;
for(ll &x: R) x=n+1-x;
reverse(R.begin(),R.end());
assert(R.size()<=150);
return {p,R};
}
std::pair<ll, std::vector<ll>> leave(ll p){
n-=p;
if(n==1){
V=R={1};
return {p,R};
}
if(n==2){
V=R={1,2};
return {p,R};
}
reverse(V.begin(),V.end());
while(V.back()<=p) V.pop_back();
for(ll &x: V) x-=p;
V.push_back(1);
V.push_back(2);
V.push_back(n-1);
V.push_back(n);
reverse(V.begin(),V.end());
sort(V.begin(),V.end());
V.resize(unique(V.begin(),V.end())-V.begin());
/*cout<<p<<": ";
for(ll x: V) cout<<x<<" ";
cout<<"\n";*/
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++){
while(NV[i]>V.end()[-1]+(V.end()[-2]+1)/2){
V.push_back(V.end()[-1]+(V.end()[-2]+1)/2);
//cout<<"push2 "<<n+1-V.back()<<"\n";
}
if(i+1<(int)NV.size()&&NV[i+1]<=V.end()[-1]+(V.end()[-2]+1)/2) continue;
V.push_back(NV[i]);
//cout<<"push "<<n+1-V.back()<<"\n";
}
R=V;
for(ll &x: R) x=n+1-x;
reverse(R.begin(),R.end());
assert(R.size()<=150);
return {p,R};
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
319 ms |
476 KB |
Correct |
3 |
Correct |
354 ms |
344 KB |
Correct |
4 |
Correct |
336 ms |
592 KB |
Correct |
5 |
Correct |
323 ms |
708 KB |
Correct |
6 |
Correct |
306 ms |
704 KB |
Correct |
7 |
Correct |
319 ms |
464 KB |
Correct |
8 |
Correct |
342 ms |
704 KB |
Correct |
9 |
Correct |
322 ms |
852 KB |
Correct |
10 |
Correct |
286 ms |
592 KB |
Correct |
11 |
Correct |
305 ms |
932 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
1 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 |
1 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 |
1 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 |
1 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 |
1 ms |
344 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Correct |
2 |
Correct |
324 ms |
708 KB |
Correct |
3 |
Correct |
331 ms |
712 KB |
Correct |
4 |
Correct |
335 ms |
708 KB |
Correct |
5 |
Correct |
334 ms |
712 KB |
Correct |
6 |
Correct |
337 ms |
600 KB |
Correct |
7 |
Correct |
319 ms |
460 KB |
Correct |
8 |
Correct |
310 ms |
464 KB |
Correct |
9 |
Correct |
319 ms |
712 KB |
Correct |
10 |
Correct |
322 ms |
452 KB |
Correct |
11 |
Correct |
317 ms |
684 KB |
Correct |
12 |
Incorrect |
1 ms |
344 KB |
Not correct |
13 |
Halted |
0 ms |
0 KB |
- |