#include "message.h"
#include <bits/stdc++.h>
using namespace std;
void send_message(std::vector<bool> M, std::vector<bool> C) {
vector<int> pos;
for (int i = 0; i < 31; i++) {
send_packet(vector<bool>(31, C[i]));
if (!C[i]) {
pos.push_back(i);
}
}
int n = M.size() - 1;
vector<bool> v(31);
for (int i = 0; i < 10; i++) {
if (n & (1 << i)) {
v[pos[i]] = 1;
}
}
send_packet(v);
for (int i = 0; i <= n; i += 16) {
vector<bool> v(31);
for (int j = i; j <= min(i + 15, n); j++) {
v[pos[j-i]] = M[j];
}
send_packet(v);
}
}
std::vector<bool> receive_message(std::vector<std::vector<bool>> R) {
vector<bool> ans;
vector<int> pos;
for (int i = 0; i < 31; i++) {
int cnt = 0;
for (bool x : R[i]) {
cnt += x;
}
if (cnt < 16) {
pos.push_back(i);
}
}
int n = 0;
for (int i = 9; i >= 0; i--) {
n = n * 2 + R[31][pos[i]];
}
for (int i = 32; i < R.size(); i++) {
for (int j = 0; j <= min(15, n); j++) {
ans.push_back(R[i][pos[j]]);
}
n -= 16;
}
return ans;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |