#include <bits/stdc++.h>
#include "message.h"
using namespace std;
void send_message(vector<bool> a, vector<bool> c) {
vector<int> zeros;
int ptr = 0;
for (; ptr < 31; ptr++) {
if (zeros.empty()) {
vector<bool> cur(31, c[ptr]);
send_packet(cur);
if (c[ptr] == 0) {
zeros.push_back(ptr);
}
} else {
vector<bool> cur(31);
vector<int> add;
for (auto j : zeros) {
if (ptr == 31) break;
if (c[ptr] == 0) {
add.push_back(ptr);
}
cur[j] = c[ptr++];
}
ptr--;
for (auto j : add) {
zeros.push_back(j);
}
send_packet(cur);
}
}
int n = a.size();
int left = n;
int i = 15;
for (; i < n; i += 16) {
left -= 16;
vector<bool> cur(31);
int k = 0;
for (int j = i - 15; j <= i; j++) {
cur[zeros[k++]] = a[j];
}
for (auto x : cur) cerr << x << ' '; cerr << '\n';
send_packet(cur);
}
i -= 16;
int f = left;
vector<bool> cnt(31);
for (auto j : zeros) {
if (left == 0) break;
cnt[j] = 1;
left--;
}
send_packet(cnt);
i++;
vector<bool> finisher(31);
int k = 0;
for (; i < a.size(); i++) {
if (f == 0) break;
f--;
finisher[zeros[k++]] = a[i];
}
send_packet(finisher);
}
vector<bool> receive_message(vector<vector<bool>> r) {
vector<bool> vis(31);
vector<int> zeros;
int i = 0, ptr = 0;
while (ptr < 31) {
if (zeros.empty()) {
int one = count(r[i].begin(), r[i].end(), 1);
int zero = 31 - one;
if (zero > one) {
zeros.push_back(ptr);
}
ptr++;
} else {
vector<int> add;
for (auto j : zeros) {
if (ptr == 31) break;
if (r[i][j] == 0) {
add.push_back(ptr);
}
ptr++;
}
for (auto j : add) {
zeros.push_back(j);
}
}
if (ptr == 31) break;
i++;
}
i++;
int n = r.size();
vector<bool> ret;
for (; i < n - 2; i++) {
for (auto j : zeros) {
ret.push_back(r[i][j]);
}
}
int cnt = 0;
for (auto j : zeros) {
cnt += r[n - 2][j];
}
for (auto j : zeros) {
if (cnt == 0) break;
cnt--;
ret.push_back(r[n - 1][j]);
}
return ret;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |