#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 {1768510133, 378973514, 467970848, 1679512799, 614816148, 1532667499, 234694455, 1912789192, 822574566, 1324909081, 87064400, 2060419247, 285468936, 1862014711, 511802188, 1635681459, 1568302423, 579181224, 78615542, 2068868105, 393266036, 1754217611, 1364481146, 783002501, 797162246, 1350321401, 1134858046, 1012625601, 922352860, 1225130787, 204306998, 1943176649, 197476141, 1950007506, 1696916194, 450567453, 1953845386, 193638261, 132126479, 2015357168, 1279353173, 868130474, 1253204423, 894279224, 253761373, 1893722274, 1336954636, 810529011, 167682211, 1979801436, 219414317, 1928069330, 1326106552, 821377095, 423582220, 1723901427, 2062924164, 84559483, 1101009288, 1046474359};
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... |