#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;
while(V.size()>=4&&n<=V.end()[-2]+V.end()[-4]) V.pop_back();
while(n>V.end()[-1]+(V.size()>=3?V.end()[-3]:1)) V.push_back(V.end()[-1]+(V.size()>=3?V.end()[-3]:1));
V.push_back(n);
R=V;
for(ll &x: R) x=n+1-x;
reverse(R.begin(),R.end());
assert(R.size()<=150);
return {5*p,R};
}
std::pair<ll, std::vector<ll>> leave(ll p){
n-=p;
if(n==1){
V=R={1};
return {5*p,R};
}
if(n==2){
V=R={1,2};
return {5*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);
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(1);
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()[-3]){
V.push_back(V.end()[-1]+V.end()[-3]);
}
//if(i+1<(int)NV.size()&&NV[i+1]<=V.end()[-1]+V.end()[-3]) continue;
V.push_back(NV[i]);
}
reverse(V.begin(),V.end());
V.pop_back();
reverse(V.begin(),V.end());
R=V;
for(ll &x: R) x=n+1-x;
reverse(R.begin(),R.end());
assert(R.size()<=150);
return {5*p,R};
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
211 ms |
452 KB |
Output is correct |
3 |
Correct |
209 ms |
452 KB |
Output is correct |
4 |
Correct |
208 ms |
448 KB |
Output is correct |
5 |
Correct |
243 ms |
428 KB |
Output is correct |
6 |
Correct |
258 ms |
448 KB |
Output is correct |
7 |
Correct |
221 ms |
444 KB |
Output is correct |
8 |
Correct |
233 ms |
432 KB |
Output is correct |
9 |
Correct |
225 ms |
428 KB |
Output is correct |
10 |
Correct |
212 ms |
448 KB |
Output is correct |
11 |
Correct |
217 ms |
416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
200 ms |
344 KB |
Output is correct |
3 |
Correct |
47 ms |
444 KB |
Output is correct |
4 |
Runtime error |
3 ms |
600 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
200 ms |
344 KB |
Output is correct |
3 |
Correct |
47 ms |
444 KB |
Output is correct |
4 |
Runtime error |
3 ms |
600 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
200 ms |
344 KB |
Output is correct |
3 |
Correct |
47 ms |
444 KB |
Output is correct |
4 |
Runtime error |
3 ms |
600 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
200 ms |
344 KB |
Output is correct |
3 |
Correct |
47 ms |
444 KB |
Output is correct |
4 |
Runtime error |
3 ms |
600 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
200 ms |
344 KB |
Output is correct |
3 |
Correct |
47 ms |
444 KB |
Output is correct |
4 |
Runtime error |
3 ms |
600 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
344 KB |
Partially correct |
2 |
Partially correct |
224 ms |
428 KB |
Partially correct |
3 |
Partially correct |
180 ms |
600 KB |
Partially correct |
4 |
Partially correct |
234 ms |
452 KB |
Partially correct |
5 |
Partially correct |
243 ms |
696 KB |
Partially correct |
6 |
Partially correct |
259 ms |
600 KB |
Partially correct |
7 |
Partially correct |
238 ms |
432 KB |
Partially correct |
8 |
Partially correct |
245 ms |
436 KB |
Partially correct |
9 |
Partially correct |
261 ms |
688 KB |
Partially correct |
10 |
Partially correct |
215 ms |
428 KB |
Partially correct |
11 |
Partially correct |
229 ms |
408 KB |
Partially correct |
12 |
Partially correct |
216 ms |
440 KB |
Partially correct |
13 |
Partially correct |
36 ms |
444 KB |
Partially correct |
14 |
Runtime error |
4 ms |
600 KB |
Execution killed with signal 6 |
15 |
Halted |
0 ms |
0 KB |
- |