#include <bits/stdc++.h>
#include "message.h"
using namespace std;
int dd[105][32], f[105];
void send_message(vector<bool> M, vector<bool> C) {
vector<int> v;
for (int i = 0; i < 31; i++) {
if (C[i] == 0) {
v.push_back(i);
}
f[i] = 0;
}
v.push_back(v[0] + 31);
for (int i = 0; i < v.size() - 1; i++) {
int h = v[i + 1] - v[i];
for (int j = 1; j < h; j++) {
dd[j][v[i]] = 0;
}
dd[h][v[i]] = 1;
f[v[i]] = h;
}
M.push_back(1);
int z = 0;
for (int i = 1; i <= 66; i++) {
for (int j = 0; j < 31; j++) {
if (i <= f[j]) continue;
dd[i][j] = 0;
if (C[j] == 1) continue;
if (z == M.size()) continue;
dd[i][j] = M[z++];
}
}
for (int i = 1; i <= 66; i++) {
vector<bool> v;
for (int j = 0; j < 31; j++) {
v.push_back(dd[i][j]);
}
send_packet(v);
}
}
int d[32];
vector<bool> receive_message(vector<vector<bool>> R) {
for (int i = 0; i < 31; i++) {
int h = 0;
for (int j = 0; j < 66; j++) {
if (R[j][i] == 1) {
h = j + 1;
break;
}
}
d[i] = h;
}
int h = -1;
for (int i = 0; i < 31; i++) {
if (d[i] == 0) continue;
int j = i, l = 0;
while (l < 16) {
j = (j + d[j]) % 31;
l++;
if (j == i) break;
}
if (l == 16 && j == i) {
h = i;
break;
}
}
vector<int> v;
for (int i = 0; i < 16; i++) {
v.push_back(h);
h = (h + d[h]) % 31;
}
vector<bool> res;
for (int i = 0; i < 66; i++) {
for (int w : v) {
if (d[w] > i) continue;
res.push_back(R[i][w]);
}
}
while (res.back() == 0) res.pop_back();
res.pop_back();
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |