#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second
using namespace std;
using ll = long long;
const ll N = 2e5+5 , inf = 2e9 + 7;
const ll INF = 1e18 , mod = 1e9+7;
vector<bool> send_packet(vector<bool> A);
void send_message(vector<bool> M, vector<bool> C) {
vector<int> vec;
reverse(all(M));
int len = M.size() , kol = 0 , pos = 0;
for(int i = 0; i < C.size(); i++){
vector<bool> A(31, C[i]);
send_packet(A);
if(C[i] == 0){
vec.push_back(i);
pos = i+1;
break;
}
}
while(M.size()){
vector<bool> A(31, 0);
vector<int> nw;
for(int x : vec){
if(pos < C.size()){
A[x] = C[pos];
if(C[pos] == 0) nw.push_back(pos);
pos++;
} else {
if(kol <= 10){
A[x] = ((len >> kol) & 1);
kol++;
} else if(M.size()){
A[x] = M.back();
M.pop_back();
}
}
}
send_packet(A);
while(nw.size()){
vec.push_back(nw.back());
nw.pop_back();
}
sort(all(vec));
}
}
vector<bool> receive_message(vector<vector<bool>> R) {
vector<bool> res , ans;
vector<int> vec;
int LEN = 0 , len = 0 , pos = 0;
for(int i = 0; i < R.size(); i++){
int kol = 0;
for(int j = 0; j < R[i].size(); j++){
kol += R[i][j];
}
if(kol >= 16) {
res.push_back(1);
} else {
res.push_back(0);
pos = i;
vec.push_back(i);
break;
}
}
for(int i = pos+1; i < R.size(); i++){
vector<int> nw;
for(int x : vec){
if(res.size() < 31){
res.push_back(R[i][x]);
if(res.back() == 0) nw.push_back(res.size()-1);
} else {
if(LEN <= 10){
len += (1 << LEN) * R[i][x];
LEN++;
} else {
if(ans.size() < len){
ans.push_back(R[i][x]);
}
}
}
// cout << x <<" ";
}
// cout << "\n";
while(nw.size()){
vec.push_back(nw.back());
nw.pop_back();
}
sort(all(vec));
}
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... |