#include "message.h"
#include<bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define sz(x) (int)x.size()
const bool keys[100]={1,1,0,1,1,1,1,0,0,1,1,1,0,1,1,0,1,1,1,1,1,0,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,1,0,1,1,1,0,0,1,0,1,1,1,1,1,1,0,1,0,1,0,0,1,1,0,1,0,1,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,0,0,1,0,1,1,0,1,1,1,0,1,0,1,1,0,1,1,0,1,1};
const int K = 95;
void send_message(std::vector<bool> M, std::vector<bool> C) {
int S=sz(M);
vector<vector<bool>> vecvec;
for(int i=0;i!=S;){
vector<bool> vec(31);
for(int j=0;j<31 && i!=S;++j) if(!C[j]) vec[j]=M[i++];
vecvec.eb(vec);
}
vector<bool> vecbitS(31);
for(int i=0,j=0;(1<<i)<=S;++i,++j){
while(C[j]) ++j;
vecbitS[j]=((S>>i)&1);
}
for(int i=0;i<K;++i) send_packet(vector<bool>(31,keys[i]));
send_packet(vecbitS);
for(auto &vec:vecvec) send_packet(vec);
}
std::vector<bool> receive_message(std::vector<std::vector<bool>> R) {
vector<bool> C(31);
for(int i=0;i<K;++i) for(int j=0;j<31;++j) C[j]=C[j]|(R[i][j]!=keys[i]);
int S=0;
for(int i=0,j=0;i<31;++i) if(!C[i]) S|=(R[K][i]<<j), ++j;
vector<bool> M(S);
for(int i=K+1,j=0;i<sz(R) && j!=S;++i){
for(int k=0;k<31 && j!=S;++k){
if(!C[k]){
M[j++]=R[i][k];
}
}
}
return M;
}
/*
1
4
0 1 1 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1
1
31
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |