# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
543087 | abc864197532 | Ancient Machine (JOI21_ancient_machine) | C++17 | 103 ms | 9172 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "Anna.h"
#include <vector>
namespace {
int variable_example = 0;
}
void Anna(int N, std::vector<char> S) {
for (int i = 0; i < N; i += 3) {
int now = 0;
for (int j = i; j < i + 3 && j < N; ++j)
now = now * 3 + S[j] - 'X';
for (int j = 4; ~j; --j)
Send(now >> j & 1);
}
}
#include "Bruno.h"
#include <vector>
#include <set>
#include <tuple>
namespace {
int variable_example = 0;
int FunctionExample(int P) { return 1 - P; }
} // namespace
void Bruno(int N, int L, std::vector<int> A) {
std::vector <char> S(N);
int pt = 0;
for (int i = 0; i < L; i += 5) {
int now = 0;
for (int j = i; j < i + 5; ++j)
now = now * 2 + A[j];
S[pt] = now / 9 + 'X';
if (pt + 1 < N)
S[pt + 1] = (now / 3) % 3 + 'X';
if (pt + 2 < N)
S[pt + 2] = now % 3 + 'X';
pt += 3;
}
std::vector <int> X, Z;
std::vector <std::pair <int, int>> Y;
std::set <int> Se;
for (int i = 0; i < N; ++i)
Se.insert(i);
for (int i = 0; i < N; ++i) {
if (S[i] == 'X')
X.push_back(i);
else if (S[i] == 'Y' && !X.empty())
Y.emplace_back(X.back(), i), X.pop_back();
else if (S[i] == 'Z' && !Y.empty()) {
int a, b; std::tie(a, b) = Y.back();
std::vector <int> del;
for (auto it = Se.lower_bound(a + 1); it != Se.end() && *it < b; ++it)
Remove(*it), del.push_back(*it);
for (auto it = Se.lower_bound(b + 1); it != Se.end() && *it < i; ++it)
Remove(*it), del.push_back(*it);
Remove(b), Remove(a), Remove(i), del.push_back(b), del.push_back(a), del.push_back(i);
for (int i : del)
Se.erase(i);
Y.pop_back();
}
while (!X.empty() && !Se.count(X.back()))
X.pop_back();
while (!Y.empty() && !Se.count(Y.back().first) && !Se.count(Y.back().second))
Y.pop_back();
}
for (int i : Se)
Remove(i);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |