# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1239015 | asdfgrace | A Light Inconvenience (CEOI23_light) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
#include "light.h"
#include "sample_grader.cpp"
#define dbg(x) x
#define prt(x) dbg(cerr << x)
#define pv(x) dbg(cerr << #x << " = " << x << '\n')
#define pv2(x) dbg(cerr << #x << " = " << x.first << ',' << x.second << '\n')
#define parr(x) dbg(prt(#x << " = { "); for (auto y : x) prt(y << ' '); prt("}\n");)
#define parr2(x) dbg(prt(#x << " = { "); for (auto [y, z] : x) prt(y << ',' << z << " "); prt("}\n");)
#define parr2d(x) dbg(prt(#x << ":\n"); for (auto arr : x) {parr(arr);} prt('\n'));
#define parr2d2(x) dbg(prt(#x << ":\n"); for (auto arr : x) {parr2(arr);} prt('\n'));
/*
only one call to leave:
since you can't know where that is
why does the leave work?
let's say you removed the last 17 and there are like 1024
so anyway
if you allow only 17 to be added after everything
then you can add from #32 and get the last 1...16
then how do you get the new 32
you can't
so then i guess after b is true
join won't always work
*/
bool b;
long long n;
vector<long long> v;
void prepare() {
b = false;
n = 1;
}
pair<long long, vector<long long>> join(long long p) {
n += p;
if (!b) {
vector<long long> v2(1, n);
for (long long x = 1; x < n - 1; x *= 2) {
v2.push_back(n - x);
}
v2.push_back(1);
reverse(v2.begin(), v2.end());
v = v2;
return make_pair(p * 5, v2);
} else {
v.push_back(n);
return make_pair(p, v);
}
}
pair<long long, vector<long long>> leave(long long p) {
b = true;
n -= p;
while (v.size() && v.back() >= n) v.pop_back();
v.push_back(n);
return make_pair(p, v);
}