# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
654452 | atigun | Flight to the Ford (BOI22_communication) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
void encode(int N, int X) {
vector<int> v;
for(int bit = 0; bit <= 2; bit++){
bool on = (X >> bit)&1;
v.push_back(send(on));
v.push_back(send(on));
while(v.end()[-1] != v.end()[-2])
v.push_back(send(on));
}
}
pair<int, int> decode(int N) {
int solution = 0;
vector<int> v;
for(int bit = 0; bit <= 2; bit++){
bool on = 0;
v.push_back(receive());
v.push_back(receive());
while(v.end()[-1] != v.end()[-2])
v.push_back(receive());
if(v.end()[-1])
solution|= (1<<bit);
}
return make_pair(solution, solution);
}