#include "message.h"
#include<bits/stdc++.h>
using namespace std;
void send_message(std::vector<bool> m, std::vector<bool> c) {
m.push_back(1);
while(m.size() < 1025) {
m.push_back(0);
}
vector<int> bruh(0);
for(int i = 0; i < 31; i++) {
if(c[i] == 0) {
bruh.push_back(i);
}
}
vector<vector<bool>> ans(0);
for(int i = 0; i < 66; i++) {
vector<bool> wut(31);
ans.push_back(wut);
}
int z = 0,p = 0;
for(int i = 0; i < 31; i++) {
if(c[i] == 0) {
int d = (bruh[(p+1)%16]-bruh[p]+31)%31;
p++;
for(int j = 0; j < 66; j++) {
if(j < d-1) {
ans[j][i] = 0;
}
else if(j == d-1) {
ans[j][i] = 1;
}
else {
ans[j][i] = m[z];
z++;
}
}
}
}
for(int i = 0; i < 66; i++) {
send_packet(ans[i]);
}
}
int calc(vector<int> haha, int p) {
vector<bool> bruh(31,true);
int br = 0;
while(true) {
bruh[p] = false;
br++;
p+=haha[p];
p%=31;
if(bruh[p] == false) {
break;
}
}
return br;
}
std::vector<bool> receive_message(std::vector<std::vector<bool>> r) {
vector<int> haha(31,-1);
for(int i = 0; i < 31; i++) {
haha[i] = 1;
for(int j = 0; j < 66; j++) {
if(r[j][i] == 0) {
haha[i]++;
}
else {
break;
}
}
}
vector<bool> c(31);
for(int i = 0; i < 31; i++) {
if(calc(haha,i) == 16) {
c[i] = false;
}
else {
c[i] = true;
}
}
vector<bool> ans(0);
for(int i = 0; i < 31; i++) {
if(c[i] == false) {
bool yeah = true;
for(int j = haha[i]; j < 66; j++) {
ans.push_back(r[j][i]);
}
}
}
while(ans[ans.size()-1] == 0) {
ans.pop_back();
}
ans.pop_back();
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... |