Submission #1073185

#TimeUsernameProblemLanguageResultExecution timeMemory
1073185NeroZeinA Light Inconvenience (CEOI23_light)C++17
100 / 100
411 ms708 KiB
#include "light.h" #include <bits/stdc++.h> using namespace std; long long tot; vector<long long> vec; void prepare(){ tot = 1; vec.push_back(1); } pair<long long, vector<long long>> join(long long p){ tot += p; for (int i = 0; i < (int) vec.size(); ++i) { vec[i] += p; } vector<long long> new_vec; for (long long x = 1; x <= tot; ) { new_vec.push_back(x); if (x == tot) { break; } auto next_one = upper_bound(vec.begin(), vec.end(), 2 * x) - vec.begin(); if (next_one != (int) vec.size() && vec[next_one] - p <= x * 2) { x = x * 2; } else { x = vec[next_one - 1]; } } vec = new_vec; vector<long long> ret = vec; for (int i = 0; i < (int) ret.size(); ++i) { ret[i] = tot - ret[i] + 1; } reverse(ret.begin(), ret.end()); return {p, ret}; } pair<long long, vector<long long>> leave(long long p){ tot -= p; for (int i = 0; i < (int) vec.size(); ++i) { vec[i] -= p; } vector<long long> new_vec; for (long long x = 1; x <= tot; ) { new_vec.push_back(x); if (x == tot) { break; } auto next_one = upper_bound(vec.begin(), vec.end(), 2 * x) - vec.begin(); if (next_one != (int) vec.size() && vec[next_one] - p <= x * 2) { x = x * 2; } else { x = vec[next_one - 1]; } } vec = new_vec; vector<long long> ret = vec; for (int i = 0; i < (int) ret.size(); ++i) { ret[i] = tot - ret[i] + 1; } reverse(ret.begin(), ret.end()); return {p, ret}; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...