#include "message.h"
//#include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
const int B = 31;
void send_message (vector <bool> m, vector <bool> c) {
for (int i = 0; i < (int)c.size(); i++) {
send_packet(vector <bool> (B, c[i]));
}
bool flag = 0;
if (m.back() == 0) {
flag = 1;
for (int i = 0; i < (int)m.size(); i++) {
m[i] = !m[i];
}
}
while ((int)m.size() % 16 != 0) {
m.push_back(0);
}
int ii[16], x = 0;
for (int i = 0; i < B; i++) {
if (!c[i]) {
ii[x++] = i;
}
}
for (int i = 0; i < (int)m.size(); i += 16) {
vector <bool> e(B);
for (int j = i; j < i + 16; j++) {
e[ii[j - i]] = m[j];
}
send_packet(e);
}
send_packet(vector <bool> (B, flag));
return;
}
int majority (vector <bool> &x) {
int c[2] = {};
for (auto i : x) {
c[i]++;
}
if (c[0] < c[1]) return 1;
else return 0;
}
vector <bool> receive_message (vector <vector <bool>> R) {
int C[B] = {};
for (int i = 0; i < B; i++) {
C[i] = majority(R[i]);
}
vector <bool> m;
return {};
for (int i = B; i + 1 < (int)R.size(); i++) {
for (int j = 0; j < B; j++) {
if (!C[j]) m.push_back(R[i][j]);
}
}
while (m.back() == 0) {
m.pop_back();
}
if (majority(R.back())) {
for (int i = 0; i < (int)m.size(); i++) {
m[i] = !m[i];
}
}
//cout << (int)R.size() << '\n';
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... |