# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
430087 | KoD | Ancient Machine (JOI21_ancient_machine) | C++17 | 86 ms | 8156 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 <bits/stdc++.h>
#include "Anna.h"
namespace {
using ll = long long;
template <class T> using Vec = std::vector<T>;
constexpr std::array<ll, 63> FIB = [] {
std::array<ll, 63> ret{};
ret[0] = 1;
ret[1] = 2;
for (int i = 2; i < 63; ++i) {
ret[i] = ret[i - 1] + ret[i - 2];
}
return ret;
}();
ll encode(const std::array<int, 63>& arr) {
ll x = 0;
for (int i = 0; i < 63; ++i) {
if (arr[i]) {
x += FIB[62 - i];
}
}
return x;
}
}
void Anna(int N, Vec<char> S) {
int idx = 0;
while (idx < N and S[idx] != 'X') {
idx += 1;
}
for (int i = 0; i < 17; ++i) {
Send(idx >> i & 1);
}
Vec<int> seq(N);
for (int i = idx + 1; i < N; ++i) {
if (S[i] == 'Z' and (i + 1 == N or S[i + 1] != 'Z')) {
seq[i] = 1;
}
}
for (int l = 0; l < N; l += 63) {
std::array<int, 63> arr;
for (int i = 0; i < 63; ++i) {
arr[i] = (l + i >= N ? 0 : seq[l + i]);
}
const ll x = encode(arr);
for (int i = 0; i < 44; ++i) {
Send(x >> i & 1);
}
}
}
#include <bits/stdc++.h>
#include "Bruno.h"
namespace {
using ll = long long;
template <class T> using Vec = std::vector<T>;
constexpr std::array<ll, 63> FIB = [] {
std::array<ll, 63> ret{};
ret[0] = 1;
ret[1] = 2;
for (int i = 2; i < 63; ++i) {
ret[i] = ret[i - 1] + ret[i - 2];
}
return ret;
}();
std::array<int, 63> decode(ll x) {
std::array<int, 63> ret{};
int idx = 0;
while (idx < 63) {
if (x >= FIB[62 - idx]) {
x -= FIB[62 - idx];
ret[idx] = 1;
idx += 2;
} else {
idx += 1;
}
}
return ret;
}
} // namespace
void Bruno(int N, int L, Vec<int> A) {
int Xpos = 0;
for (int i = 0; i < 17; ++i) {
Xpos |= A[i] << i;
}
int idx = 0;
Vec<int> vec;
for (int i = 17; i < L; i += 44) {
ll x = 0;
for (int k = 0; k < 44; ++k) {
x |= (ll) A[i + k] << k;
}
for (const auto y : decode(x)) {
if (y) {
vec.push_back(idx);
}
idx += 1;
}
}
Vec<int> removed(N);
for (const auto i : vec) {
for (int j = i - 1; j > Xpos; --j) {
Remove(j);
removed[j] = true;
}
Remove(i);
removed[i] = true;
Xpos = i;
}
for (int i = 0; i < N; ++i) {
if (!removed[i]) {
Remove(i);
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |