# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
684509 | mjhmjh1104 | Ancient Machine (JOI21_ancient_machine) | C++17 | 57 ms | 8572 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>
using namespace std;
unsigned long long dp[99][2];
void Anna(int n, vector<char> s) {
int k = 0;
bool skip = false;
vector<int> v;
for (int i = 0; i < n; i++) {
if (skip) skip = false;
else if (s[i] == 'X') v.push_back(1), v.push_back(0), skip = true;
else v.push_back(0);
if (s[i] == 'Z') k = i;
}
while ((int)v.size() > n) v.pop_back();
dp[62][0] = dp[62][1] = 1;
for (int i = 61; i >= 0; i--) {
dp[i][0] = dp[i + 1][0] + dp[i + 1][1];
dp[i][1] = dp[i + 1][0];
}
vector<int> curr;
for (int i = 0; i < n; i += 63) {
curr.clear();
for (int j = i; j < i + 63 && j < n; j++) curr.push_back(v[j]);
while ((int)curr.size() < 63) curr.push_back(0);
long long m = 0;
for (int i = 0; i < 63; i++) if (curr[i]) m += dp[i][0];
for (int i = 0; i < 44; i++) Send(m & 1LL << i ? 1 : 0);
}
for (int t = 0; t <= 16; t++) Send(k & 1 << t ? 1 : 0);
}
#include "Bruno.h"
#include <vector>
using namespace std;
unsigned long long dp[99][2];
void Bruno(int n, int l, vector<int> b) {
dp[62][0] = dp[62][1] = 1;
for (int i = 61; i >= 0; i--) {
dp[i][0] = dp[i + 1][0] + dp[i + 1][1];
dp[i][1] = dp[i + 1][0];
}
int lt = n, rt = 0;
vector<int> a;
for (int i = 0; i < (int)b.size() - 17; i += 44) {
long long m = 0;
for (int j = 0; j < 44; j++) if (b[i + j]) m |= 1LL << j;
for (int i = 0; i < 63; i++) {
if (m >= dp[i][0]) {
m -= dp[i][0];
a.push_back(1);
} else a.push_back(0);
}
}
while ((int)a.size() > n) a.pop_back();
for (int i = (int)b.size() - 17; i < (int)b.size(); i++) a.push_back(b[i]);
for (int t = 0; t <= 16; t++) if (a[n + t]) rt |= 1 << t;
for (int i = n - 1; i >= 0; i--) if (a[i] || !i) {
for (int j = i + 1; j < lt; j++) if (a[j]) Remove(j);
for (int j = i + 1; j < lt; j++) if (!a[j] && j != rt) Remove(j);
if (i != rt) Remove(i);
lt = i;
}
Remove(rt);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |