#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 < 30; i++) {
send_packet(vector<bool>(31, C[i]));
if (!C[i]) {
pos.push_back(i);
}
}
if (pos.size() == 15) {
pos.push_back(30);
}
M.insert(M.begin(), true);
while (M.size() < 1040) {
M.insert(M.begin(), false);
}
for (int i = 0; i < 1040; i += 16) {
vector<bool> v(31);
for (int j = i; j < i + 16; 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 < 30; i++) {
int cnt = 0;
for (bool x : R[i]) {
cnt += x;
}
if (cnt < 16) {
pos.push_back(i);
}
}
if (pos.size() == 15) {
pos.push_back(30);
}
bool flag = false;
for (int i = 30; i < R.size(); i++) {
for (int j = 0; j < 16; j++) {
if (flag) {
ans.push_back(R[i][pos[j]]);
}
if (R[i][pos[j]]) {
flag = true;
}
}
}
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... |