#include "message.h"
#include <bits/stdc++.h>
using namespace std;
void send_message(vector<bool> M, vector<bool> C) {
for (int i = 0; i < 31; i++) {
vector<bool> p(31, C[i]);
send_packet(p);
}
int S = M.size();
vector<bool> bits;
for (int i = 9; i >= 0; i--) bits.push_back((S >> i) & 1);
for (bool b : M) bits.push_back(b);
vector<int> safe;
for (int i = 0; i < 31; i++) if (!C[i]) safe.push_back(i);
int blocks = (bits.size() + 15) / 16;
for (int b = 0; b < blocks; b++) {
vector<bool> p(31, false);
for (int i = 0; i < 16; i++) {
int k = b * 16 + i;
if (k < (int)bits.size()) p[safe[i]] = bits[k];
}
send_packet(p);
}
}
vector<bool> receive_message(vector<vector<bool>> R) {
vector<int> C(31);
for (int i = 0; i < 31; i++) {
int ones = 0;
for (bool b : R[i]) ones += b;
C[i] = (ones > 15);
}
vector<int> safe;
for (int i = 0; i < 31; i++) if (!C[i]) safe.push_back(i);
vector<bool> bits;
for (int i = 31; i < (int)R.size(); i++)
for (int j = 0; j < 16; j++)
bits.push_back(R[i][safe[j]]);
int S = 0;
for (int i = 0; i < 10; i++) S = (S << 1) | bits[i];
vector<bool> M(S);
for (int i = 0; i < S; i++) M[i] = bits[10 + i];
return M;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |