#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) {
	reverse(all(M));
	int len = M.size() , kol = 0;
	for(int i = 0; i < C.size(); i++){
		vector<bool> A(31, C[i]);
		for(int j = 0; j < i; j++){
			if(C[j] == 0 && kol <= 10){
				A[j] = ((len >> kol) & 1);
				kol++;
			} else if(C[j] == 0 && M.size()){
				A[j] = M.back();
				M.pop_back();
			} 
		}
		send_packet(A);
	}
	while(M.size()){
		vector<bool> A(31, 0);
		for(int j = 0; j < C.size(); j++){
			if(C[j] == 0 && M.size()){
				A[j] = M.back();
				M.pop_back();
			}
		}
		send_packet(A);
	}
}
vector<bool> receive_message(vector<vector<bool>> R) {
	vector<bool> res , ans;
	int LEN = 0 , len = 0;
	for(int i = 0; i < R.size(); i++){
		int kol = 0;
		for(int j = 0; j < R[i].size(); j++){
			if(j < i){
				if(res[j] == 0 && LEN <= 10){
					len += (1 << LEN) * R[i][j];
					LEN++;
				} else if(res[j] == 0 && ans.size() < len){
					ans.push_back(R[i][j]);
				} 
				kol += res[j];
			} else {
				kol += R[i][j];
			}
		} 
		if(kol >= 16) res.push_back(1);
		else res.push_back(0);
	}
	for(int i = 31; i < R.size(); i++){
		for(int j = 0; j < R[i].size(); j++){
			if(res[j] == 0 && ans.size() < len) ans.push_back(R[i][j]);
		}
	}
	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... |