# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1056471 | juicy | Ancient Machine (JOI21_ancient_machine) | C++17 | 4 ms | 2004 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
template<class T>
ostream &operator << (ostream &os, vector<T> v) {
int D = v.size();
os << "{";
for (int i = 0; i < D; ++i) {
os << (i ? ", " : "") << v[i];
}
return os << "}";
}
void __print() {
cerr << "]\n";
}
template<class T, class... V>
void __print(T t, V... v) {
cerr << t;
if (sizeof...(v)) {
cerr << ", ";
}
__print(v...);
}
#define debug(x...) cerr << "[" << #x << "] = ["; __print(x);
}
void Anna(int N, std::vector<char> S) {
int B = 63, K = 44;
vector<long long> fib(B);
fib[0] = fib[1] = 1;
for (int i = 2; i < B; ++i) {
fib[i] = fib[i - 1] + fib[i - 2];
}
auto encode = [&](vector<int> msg) {
long long res = 0;
for (int i = B - 1; i >= 0; --i) {
res += msg[B - i - 1] * fib[i];
}
return res;
};
int p = 0;
vector<int> msg;
while (p < N && S[p] != 'X') {
++p;
msg.push_back(0);
}
if (p < N) {
msg.push_back(1);
msg.push_back(0);
++p;
}
for (; p < N; ++p) {
if (S[p] == 'Z' && (p + 1 == N || S[p + 1] != S[p])) {
msg.push_back(1);
} else {
msg.push_back(0);
}
}
while (msg.size() % B) {
msg.push_back(0);
}
for (int i = 0; i < msg.size(); i += B) {
auto x = encode(vector(msg.begin() + i, msg.begin() + B));
for (int j = 0; j < K; ++j) {
Send(x >> j & 1);
}
}
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
void __print() {
cerr << "]\n";
}
template<class T, class... V>
void __print(T t, V... v) {
cerr << t;
if (sizeof...(v)) {
cerr << ", ";
}
__print(v...);
}
#define debug(x...) cerr << "[" << #x << "] = ["; __print(x);
}
void Bruno(int N, int L, std::vector<int> A) {
int B = 63, K = 44;
vector<long long> fib(B);
fib[0] = fib[1] = 1;
for (int i = 2; i < B; ++i) {
fib[i] = fib[i - 1] + fib[i - 2];
}
auto decode = [&](long long x) {
string msg;
for (int i = B - 1; i >= 0; --i) {
if (x >= fib[i]) {
msg += '1';
x -= fib[i];
} else {
msg += '0';
}
}
return msg;
};
string S;
for (int i = 0; i < L; i += K) {
long long x = 0;
for (int j = 0; j < K; ++j) {
if (A[i + j]) {
x += 1LL << j;
}
}
S += decode(x);
}
int p = 0;
while (p < N && S[p] == '0') {
Remove(p++);
}
if (p == N) {
return;
}
int i = p + 2, lst = i;
for (; i <= N; ++i) {
if (S[i] == '1') {
for (int j = i - 1; j >= lst; --j) {
Remove(j - 1);
}
Remove(i - 1);
lst = i + 1;
}
}
for (i = N; i >= lst; --i) {
Remove(i - 1);
}
Remove(p);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |