#include "light.h"
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
using namespace std;
ll n, maxi;
vector<ll> prevs;
void prepare(){
n = 1;
maxi = n;
prevs = {1};
}
pair<long long, std::vector<long long>> join(long long p){
n += p;
set<ll> stuff;
stuff.insert(1);
stuff.insert(n);
for (auto&i : prevs){
if (i != 1) stuff.insert(i+p);
}
vector<ll> real;
for (auto&i : stuff) if (1<=i && i<=n) real.push_back(i);
vector<ll> spare;
FORNEG(i, real.size()-1, 0){
//cout << (n-real[i] + 1) << " " << (real[i] - real[i-1] - 1) << endl;
while ((n-real[i] + 1) < (real[i] - real[i-1] - 1)){
spare.push_back(real[i]);
real[i] = n - (n-real[i] + 1)*2;
}
}
for (auto&i : spare) real.push_back(i);
sort(real.begin(), real.end());
prevs = real;
return {p*5,real};
}
std::pair<long long, std::vector<long long>> leave(long long p){
n -= p;
set<ll> stuff;
stuff.insert(1);
stuff.insert(n);
for (auto&i : prevs){
if (i != 1) stuff.insert(i);
}
vector<ll> real;
for (auto&i : stuff) if (1<=i && i<=n) real.push_back(i);
vector<ll> spare;
FORNEG(i, real.size()-1, 0){
//cout << (n-real[i] + 1) << " " << (real[i] - real[i-1] - 1) << endl;
while ((n-real[i] + 1) < (real[i] - real[i-1] - 1)){
spare.push_back(real[i]);
real[i] = n - (n-real[i] + 1)*2;
}
}
for (auto&i : spare) real.push_back(i);
sort(real.begin(), real.end());
prevs = real;
return {p*5,real};
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
421 ms |
440 KB |
Output is correct |
3 |
Correct |
463 ms |
416 KB |
Output is correct |
4 |
Correct |
462 ms |
420 KB |
Output is correct |
5 |
Correct |
413 ms |
424 KB |
Output is correct |
6 |
Correct |
470 ms |
592 KB |
Output is correct |
7 |
Correct |
448 ms |
416 KB |
Output is correct |
8 |
Correct |
451 ms |
420 KB |
Output is correct |
9 |
Correct |
431 ms |
424 KB |
Output is correct |
10 |
Correct |
419 ms |
420 KB |
Output is correct |
11 |
Correct |
398 ms |
420 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
340 ms |
344 KB |
Output is correct |
3 |
Correct |
77 ms |
344 KB |
Output is correct |
4 |
Incorrect |
1 ms |
344 KB |
Not correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
340 ms |
344 KB |
Output is correct |
3 |
Correct |
77 ms |
344 KB |
Output is correct |
4 |
Incorrect |
1 ms |
344 KB |
Not correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
340 ms |
344 KB |
Output is correct |
3 |
Correct |
77 ms |
344 KB |
Output is correct |
4 |
Incorrect |
1 ms |
344 KB |
Not correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
340 ms |
344 KB |
Output is correct |
3 |
Correct |
77 ms |
344 KB |
Output is correct |
4 |
Incorrect |
1 ms |
344 KB |
Not correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
340 ms |
344 KB |
Output is correct |
3 |
Correct |
77 ms |
344 KB |
Output is correct |
4 |
Incorrect |
1 ms |
344 KB |
Not correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
Partially correct |
2 |
Partially correct |
407 ms |
420 KB |
Partially correct |
3 |
Partially correct |
464 ms |
592 KB |
Partially correct |
4 |
Partially correct |
432 ms |
424 KB |
Partially correct |
5 |
Partially correct |
452 ms |
424 KB |
Partially correct |
6 |
Partially correct |
441 ms |
420 KB |
Partially correct |
7 |
Partially correct |
446 ms |
592 KB |
Partially correct |
8 |
Partially correct |
439 ms |
416 KB |
Partially correct |
9 |
Partially correct |
498 ms |
344 KB |
Partially correct |
10 |
Partially correct |
451 ms |
424 KB |
Partially correct |
11 |
Partially correct |
399 ms |
596 KB |
Partially correct |
12 |
Partially correct |
328 ms |
344 KB |
Partially correct |
13 |
Partially correct |
72 ms |
592 KB |
Partially correct |
14 |
Incorrect |
1 ms |
344 KB |
Not correct |
15 |
Halted |
0 ms |
0 KB |
- |