#include <bits/stdc++.h>
#include "message.h"
using namespace std;
void send_message(vector<bool> M, vector<bool> C){
for (int i=0; i<31; i++){
vector<bool> bit_message;
if (C[i] == 0){
for (int j=0; j<31; j++) bit_message.push_back(0);
}
else{
for (int j=0; j<31; j++) bit_message.push_back(1);
}
send_packet(bit_message);
}
int msg_len = M.size();
vector<bool> pad_message;
while (pad_message.size()+1+msg_len < 1025) pad_message.push_back(0);
pad_message.push_back(1);
for (auto it : M) pad_message.push_back(it);
//assert(pad_message.size() == 1025);
int cnt = 0;
for (int i=0; i<65; i++){
vector<bool> ans(31);
for (int j=0; j<31; j++){
if (j+cnt > 1024) break;
if (C[j] == 0) ans[j] = pad_message[j+cnt];
}
cnt += 31;
send_packet(ans);
}
}
vector<bool> receive_message(vector<vector<bool>> R){
vector<bool> C; //to reflect the same version as C in send_message
for (int i=0; i<31; i++){
int zro = 0, one = 0;
for (bool it : R[i]){
if (it == 0) zro++;
else one++;
}
if (zro > one) C[i] = 0;
else C[i] = 1;
}
bool seen = false;
int check_cnt = 0;
vector<bool> ans;
for (vector<bool> v : R){
for (bool it : v){
check_cnt++;
if (check_cnt > 1025) break;
if (it == 1 && !seen){
seen = true;
continue;
}
if (seen) ans.push_back(it);
}
if (check_cnt > 1025) break;
}
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... |