# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
868040 | TAhmed33 | 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>
#include <communication.h>
using namespace std;
void encode (int n, int x) {
for (int i = 1; i <= x; i++) send(1);
for (int i = x + 1; i <= n; i++) send(0);
}
pair <int, int> decode (int n) {
vector <int> u; for (int i = 0; i < 3; i++) u.push_back(receive());
if (u == {1, 1, 1} || u == {1, 1, 0} || u == {0, 1, 0}) {
return {2, 3};
}
if (u == {0, 1, 1}) {
return {2, 3};
}
if (u == {1, 0, 1}) {
return {1, 3};
}
if (u == {0, 0, 0}) {
return {1, 1};
}
if (u == {0, 0, 1}) {
return {1, 1};
}
if (u == {1, 0, 0}) {
return {2, 2};
}
}