#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int ul;
typedef unsigned long long ull;
#define MASK(i) (1ULL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
#define ALL(v) (v).begin(), (v).end()
ll gcd(ll a, ll b){return __gcd(a, b);}
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll LASTBIT(ll mask){return (mask) & (-mask);}
int pop_cnt(ll mask){return __builtin_popcountll(mask);}
int ctz(ull mask){return __builtin_ctzll(mask);}
int logOf(ull mask){return 63 - __builtin_clzll(mask);}
// mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rng(1);
ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);}
template <class T1, class T2>
bool maximize(T1 &a, T2 b){
if (a < b) {a = b; return true;}
return false;
}
template <class T1, class T2>
bool minimize(T1 &a, T2 b){
if (a > b) {a = b; return true;}
return false;
}
template <class T>
void printArr(T the_array_itself, string separator = " ", string finish = "\n", ostream &out = cout){
for(auto item: the_array_itself) out << item << separator;
out << finish;
}
template <class T>
void remove_dup(vector<T> &a){
sort(ALL(a));
a.resize(unique(ALL(a)) - a.begin());
}
#include "message.h"
void send_message(vector<bool> M, std::vector<bool> C){
vector<int> pos;
for(bool i: C) {
send_packet(vector<bool>(31, i));
}
for(int i = 0; i < 31; ++i) if (C[i] == 0)
pos.push_back(i);
vector<bool> vro;
for(int i = 0; i < 10; ++i) vro.push_back(GETBIT(M.size(), i));
for(bool i: M) vro.push_back(i);
while(vro.size() % 16) vro.push_back(0);
if (vro.size() / 16 + 31 >= 100) assert(false);
for(int i = 0; i < (int)vro.size(); i += 16){
vector<bool> cur(31);
for(int j = 0; j < 16; ++j){
cur[pos[j]] = vro[i + j];
}
send_packet(cur);
}
}
vector<bool> receive_message(vector<vector<bool>> R){
vector<bool> C(31);
for(int i = 0; i< 31; ++i){
int cnt = 0;
for(int j: R[i]) cnt += j;
if (cnt > 15) C[i] = 1;
}
vector<bool> vro;
for(int i = 31; i < (int) R.size(); ++i){
for(int j = 0; j < 31; ++j) if (C[j] == 0)
vro.push_back(R[i][j]);
}
int sz = 0;
for(int i = 0; i < 10; ++i) if (vro[i]) sz += MASK(i);
while(vro.size() > sz + 10) vro.pop_back();
vector<bool> message;
for(int i = 10; i < (int) vro.size(); ++i) message.push_back(vro[i]);
return message;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |