#include "message.h"
#include <bits/stdc++.h>
using namespace std;
using vb = vector<bool>;
using vvb = vector<vb>;
// strategy 1 (should get 10 points for S <= 64)
// send S packets. if the majority of bits in a packet are 1, then M[i] = 1. else M[i] = 0
// we have 16 (majority) of bits to ourself, so strat always works
// M = message to send, len(M) <= 1024
// C = bitmask of tainted bits, len(C) = 31
// if C[i] = 0, then that bit is safe, otherwise that bit isnt
// 15 unsafe, 16 safe
void send_message(vb M, vb C) {
vb ZERO = vb(31, false);
vb ONE = vb(31, true);
for (int i = 0; i < M.size(); i++) {
if (M[i] == false) send_packet(ZERO);
else send_packet(ONE);
}
}
vb receive_message(vvb R) {
vb M;
for (auto &el : R) {
int ZEROS = 0; for (int i = 0; i < 31; i++) ZEROS += el[i] == false;
if (ZEROS >= 16) M.push_back(false);
else M.push_back(true);
}
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... |