#include <bits/stdc++.h>
#include "message.h"
using namespace std;
using ll = long long;
vector <vector<bool>> r;
void send_message(vector<bool> M, vector<bool> C){
ll first_index=-1;
ll index=0;
vector <bool> vec_true(31,true);
vector <bool> vec_false(31,false);
vector <ll> idx;
if (M.size()<=4){
for (int i=0; i<M.size(); i++){
if (M[i]){send_packet(vec_true);}
else{send_packet(vec_false);}
}
}
else{
while ((first_index+1)==0){
if (!C[index]){first_index=index;}
index++;
}
for (int i=0; i<31; i++){
if (!C[i]){idx.push_back(i);}
}
ll n = M.size(), xx = 4;
vector <ll> bits_of_first_index;
vector <ll> bits_of_random_index;
while (xx--){
if (first_index%2){bits_of_first_index.push_back(1);}
else{bits_of_first_index.push_back(0);}
first_index/=2;
}
first_index=idx[0];
for (int i=1; i<16; i++){
ll num = idx[i]-idx[i-1];
for (int j=0; j<4; j++){
if (num%2){bits_of_random_index.push_back(1);}
else{bits_of_random_index.push_back(0);}
num/=2;
}
}
for (int i=max(0LL,n-5); i<n; i++){
bits_of_random_index.push_back(M[i]);
}
bits_of_random_index.push_back(true);
for (int i=0; i<max(5-n,0LL)+2; i++){bits_of_random_index.push_back(false);}
for (int i=0; i<4; i++){
vector <bool> tm = vec_false;
for (int j=0; j<16; j++){
if (bits_of_first_index[i]){
tm[idx[j]]=true;
}
}
send_packet (tm);
}
for (int i=0; i<68; i++){
vector <bool> tm = vec_false;
tm[first_index]=bits_of_random_index[i];
int j=1;
for (; j<16 && M.size()-5>i*15+j-1; j++){
tm[idx[j]]=M[i*15+j-1];
}
if (M.size()-5==i*15+j-1){tm[idx[j]]=true;}
send_packet(tm);
}}
}
vector<bool> receive_message(vector<vector<bool>> R){
if (R.size()<=4){
vector <bool> ans;
for (int i=0; i<R.size(); i++){
ll sm=0;
for (int j=0; j<31; j++){
if (R[i][j]){sm++;}
}
if (sm>=16){ans.push_back(true);}
else{ans.push_back(false);}
}
return ans;
}
else{
ll first_idx=0;
for (int i=0; i<4; i++){
ll sm=0;
for (int j=0; j<31; j++){
if (R[i][j]){sm++;}
}
if (sm>=16){first_idx+=(1<<i);}
}
vector <ll> idx;
idx.push_back(first_idx);
ll sm = first_idx;
for (int i=4; i<72; i=i+4){
if (i<64){
ll index=0;
for (int j=0; j<4; j++){
if (R[i+j][first_idx]){index+=(1<<j);}
}
sm+=index;
idx.push_back(sm);
}
}
for (auto x : idx){cout<<x<<' ';}
cout<<"\n";
cout<<"\n";
vector <bool> ans;
for (int i=4; i<72; i++){
for (int j=1; j<16; j++){
if (R[i][idx[j]]){
ans.push_back(true);
}
else{ans.push_back(false);}
}
}
ll stop=1;
for (int i=71; i>0 && stop ; i--){
for (int j=15; j>=1 && stop; j--){
if (R[i][idx[j]]){
stop=0;
}
ans.pop_back();
}
}
for (int i=64; i<72; i++){
if (R[i][first_idx]){
ans.push_back(true);
}
else{
ans.push_back(false);
}
}
stop=1;
for (int i=71; i>=64 && stop; i--){
if (R[i][first_idx]){
stop=0;
}
ans.pop_back();
}
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... |