| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 666502 | rainboy | Ancient Machine (JOI21_ancient_machine) | C++17 | 0 ms | 0 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 <cassert>
#include <vector>
using namespace std;
typedef vector<char> str;
namespace A {
const int N = 100001, K = 63, L = 44, M = 70000;
long long ff[K + 1];
void init() {
ff[0] = 1, ff[1] = 2;
for (int i = 2; i <= K; i++)
ff[i] = ff[i - 1] + ff[i - 2];
assert(1LL << L >= ff[K] && (N + K - 1) / K * L <= M);
}
}
void encode(str aa, int n) {
for (int i = 0; i < n; i += A::K) {
long long x = 0;
for (int j = 0; j < A::K && i + j < n; j++)
if (aa[i + j] == 1)
x += A::ff[j];
for (int l = 0; l < A::L; l++)
Send(x >> l & 1);
}
}
void Anna(int n, str cc) {
A::init();
int ix = 0;
while (ix < n && cc[ix] != 'X')
ix++;
int iz = n - 1;
while (iz >= 0 && cc[iz] != 'Z')
iz--;
str aa(n + 1, 0);
if (ix < iz) {
aa[ix] = 1;
for (int i = ix + 1; i < iz; i++)
if (cc[i] == 'Z' && cc[i + 1] == 'Y')
aa[i + 1] = 1;
aa[iz + 1] = 1;
}
encode(aa, n + 1);
}
