#include "message.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int SEED = 87041;
const int MOD = 16;
const int N = 31;
void send_message(std::vector<bool> M, std::vector<bool> C) {
M.pb(1);
vector<int> ok;
for (int i=0; i<N; i++) if (!C[i]) ok.pb(i);
int id = M.size() * SEED % MOD;
int f = ok[id];
vector<vector<bool>> send;
for (int i=0; i<N; i++) {
vector<bool> vec(N);
vec[f] = C[i];
send.pb(vec);
}
int p = 0, q = 0;
for (int i=0; i < M.size(); i++) {
while (C[q] || (p<N && q==f)) {
q++;
if (q==N) p++, q=0;
}
if (p==send.size()) send.pb(vector<bool>(N));
send[p][q] = M[i];
q++;
if (q==N) p++, q=0;
}
for (auto vec : send) send_packet(vec);
}
std::vector<bool> receive_message(std::vector<std::vector<bool>> R) {
for (int f=0; f<N; f++) {
vector<bool> C(N);
for (int i=0; i<N; i++) C[i] = R[i][f];
vector<int> ok;
for (int i=0; i<N; i++) if (!C[i]) ok.pb(i);
if (ok.size() != 16 || C[f]) continue;
vector<bool> M;
for (int i=0; i<R.size(); i++) {
for (int j=0; j<N; j++) {
if (C[j] || (i<N && j==f)) continue;
M.pb(R[i][j]);
}
}
while (!M.empty() && !M.back()) M.pop_back();
if (!M.empty()) M.pop_back();
int id = (M.size() + 1) * SEED % MOD;
if (ok[id] == f) return M;
}
return {};
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |