This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "message.h"
#include <bits/stdc++.h>
using namespace std;
void send_message(vector<bool> M, vector<bool> C) {
vector<bool> A(31, 0);
vector<int> B;
for (int i = 0; i < 31; i++) {
fill(A.begin(), A.end(), !C[i]);
send_packet(A);
if (!C[i])
B.push_back(i);
if (B.size() == 5) {
for (int j = i + 1; j < 31; j++) {
if (!C[j]) {
B.push_back(j);
continue;
}
for (int k = 0; k < 5; k++)
A[B[k]] = j & (1 << k);
send_packet(A);
}
break;
}
}
int S = M.size();
for (int j = 0; j < 10; j++)
A[B[j]] = S & (1 << j);
send_packet(A);
for (int i = 0; i < (S + 15) / 16; i++) {
for (int j = 0; j < 16 && 16 * i + j < S; j++)
A[B[j]] = M[16 * i + j];
send_packet(A);
}
}
vector<bool> receive_message(vector<vector<bool>> R) {
vector<bool> res, C(31, 1);
vector<int> cor, nt;
int cnt = 0, val, S = 0;
for (int i = 0; i < R.size(); i++) {
cnt = 0;
for (bool j : R[i])
cnt += j;
if (cnt >= 16)
cor.push_back(i);
else
nt.push_back(i);
if (cor.size() == 5) {
for (int j = i; j < 20; j++) {
val = 0;
for (int k = 4; k >= 0; k--)
val = val << 1 | R[j][cor[k]];
nt.push_back(val);
}
break;
}
}
for (int i : nt)
C[i] = 0;
for (int i = 0; i < 31; i++)
if (C[i])
cor.push_back(i);
for (int i = 9; i >= 0; i--)
S = S << 1 | R[20][cor[i]];
for (int i = 21; i < R.size(); i++)
for (int j = 0; j < 16; j++)
if ((i - 21) * 16 + j < S)
res.push_back(R[i][cor[j]]);
return res;
}
Compilation message (stderr)
message.cpp: In function 'std::vector<bool> receive_message(std::vector<std::vector<bool> >)':
message.cpp:47:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | for (int i = 0; i < R.size(); i++) {
| ~~^~~~~~~~~~
message.cpp:76:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
76 | for (int i = 21; i < R.size(); i++)
| ~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |