# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
592540 | cheissmart | 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 <vector>
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;
namespace {
string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m";
void DBG() { cerr << "]" << _reset << endl; }
template<class H, class...T> void DBG(H h, T ...t) {
cerr << to_string(h);
if(sizeof ...(t)) cerr << ", ";
DBG(t...);
}
#define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
const int INF = 1e9 + 7;
ll fib[70];
}
void Anna(int n, V<char> s) {
int pos = n - 1;
for(int i = 0; i < n; i++)
if(s[i] == 'X') {
pos = i;
break;
}
for(int i = 0; i < 17; i++)
Send(pos >> i & 1);
V<bool> he(n);
for(int i = pos + 1; i < n; i++)
if(s[i] == 'Z' && (i + 1 >= n || s[i + 1] != 'Z'))
he[i] = true;
fib[0] = fib[1] = 2;
for(int i = 2; i < 70; i++)
fib[i] = fib[i - 1] + fib[i - 2];
for(int i = 0; i < n; i += 70) {
ll tt = 0;
for(int j = i; j < n && j < i + 70; j++)
tt += he[j] * fib[j - i];
assert(tt < (1LL << 48));
for(int j = 0; j < 48; j++)
Send(tt >> j & 1);
}
}