#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second
using namespace std;
using ll = long long;
const ll N = 2e5+5 , inf = 2e9 + 7;
const ll INF = 1e18 , mod = 1e9+7;
vector<bool> send_packet(vector<bool> A);
void send_message(vector<bool> M, vector<bool> C) {
for(int i = 0; i < C.size(); i++){
vector<bool> A(31, C[i]);
send_packet(A);
}
vector<bool> X(31, 0);
int len = M.size();
for(int i = 0 , j = 0; i <= 30; i++){
if(C[i] == 0){
X[i] = ((len >> j) & 1);
j++;
}
}
send_packet(X);
for(int i = 0; i < M.size();){
vector<bool> A(31, 0);
for(int j = 0; j < C.size(); j++){
if(C[j] == 0 && i < M.size()){
A[j] = M[i];
i++;
}
}
send_packet(A);
}
}
vector<bool> receive_message(vector<vector<bool>> R) {
vector<bool> res , ans;
for(int i = 0; i < 31; i++){
int kol = 0;
for(int j = 0; j < R[i].size(); j++) kol += R[i][j];
if(kol >= 16) res.push_back(1);
else res.push_back(0);
}
int len = 0;
for(int i = 31; i <= 31; i++){
for(int j = 0 , k = 0; j < R[i].size(); j++){
if(res[j] == 0){
len += (1 << k) * R[i][j];
k++;
}
}
}
for(int i = 32; i < R.size(); i++){
for(int j = 0; j < R[i].size(); j++){
if(res[j] == 0 && ans.size() < len){
ans.push_back(R[i][j]);
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |