#include "message.h"
#include <bits/stdc++.h>
using namespace std;
#define N 100001
#define nl '\n'
#define ff first
#define ss second
#define ll long long
#define ld long double
#define terminator main
#define pll pair<ll,ll>
#define append push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<int> v {874674419, 1272809228, 1903646809, 243836838, 1381748497, 765735150, 51156937, 2096326710, 50857436, 2096626211, 1255551421, 891932226, 2054315402, 93168245, 1373098914, 774384733, 765572909, 1381910738, 265825162, 1881658485, 747085087, 1400398560, 698317152, 1449166495, 64720420, 2082763227, 371049803, 1776433844, 1183887005, 963596642, 1335513340, 811970307, 1296545378, 850938269, 571690506, 1575793141, 358181733, 1789301914, 1464224660, 683258987, 745624913, 1401858734, 1631673195, 515810452, 791078971, 1356404676, 1773405600, 374078047, 1927666813, 219816834, 1133619321, 1013864326, 1202130456, 945353191, 1286524815, 860958832, 1914789251, 232694396, 1204351932, 943131715};
int p[31];
void send_message(vector<bool> M, vector<bool> c) {
vector<bool> a(31, 0);
p[0] = 1;
for(int i = 1; i < 31; i++)
p[i] = p[i - 1] * 2;
for(auto & i : v){
for(int j = 0; j < 31; j++){
if(c[j]) continue;
a[j] = ((i & p[j]) == p[j]);
}
send_packet(a);
}
int s = M.size(), t = 0;
for(int i = 0; i < 31; i++){
if(c[i]) continue;
a[i] = ((s & p[t]) == p[t]);
t++;
}
send_packet(a);
t = 0;
while(t < s){
for(int i = 0; i < 31; i++){
if(c[i] || t == s) continue;
a[i] = M[t];
t++;
}
send_packet(a);
}
}
vector<bool> receive_message(vector<vector<bool>> R) {
vector<bool> M, c(31, 0);
for(int i = 0; i < v.size(); i++)
for(int j = 0; j < 31; j++)
if(bool((v[i] & p[j]) == p[j]) != R[i][j])
c[j] = 1;
int s = 0, t = 0;
for(int i = 0; i < 31; i++){
if(c[i]) continue;
if(R[v.size()][i]) s += p[t];
t++;
}
t = 0;
for(int i = v.size() + 1; i < R.size(); i++){
for(int j = 0; j < 31; j++){
if(c[j] || t == s) continue;
M.append(R[i][j]);
t++;
}
}
return M;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |