# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
592542 | cheissmart | Ancient Machine (JOI21_ancient_machine) | C++17 | 48 ms | 7432 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];
for(int j = 0; j < 49; j++)
Send(tt >> j & 1);
}
}
#include "Bruno.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...);
}
#ifdef CHEISSMART
#define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define debug(...)
#endif
const int INF = 1e9 + 7;
ll fib[70];
}
void Bruno(int n, int l, vi a) {
int pos = 0;
for(int i = 0; i < 17; i++)
pos |= a[i] << i;
int sz = 17;
vi zs;
V<bool> be(n);
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 = 0; j < 49; j++)
tt += a[sz++] * (1LL << j);
for(int j = 69; j >= 0; j--) {
if(tt >= fib[j]) {
be[i + j] = true;
tt -= fib[j];
}
}
assert(tt == 0);
}
for(int i = 0; i < n; i++) if(be[i]) {
zs.PB(i);
}
vi aux;
for(int i = 0; i <= pos; i++)
aux.PB(i);
reverse(ALL(zs));
for(int i = pos + 1; i < n; i++) {
if(SZ(zs) && zs.back() == i) {
zs.pop_back();
while(aux.back() != pos) {
Remove(aux.back());
aux.pop_back();
}
Remove(i);
} else {
aux.PB(i);
}
}
for(int i:aux)
Remove(i);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |