# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
651098 | TimDee | 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>
pair<int,int> decode(int n) {
mt19937 rng(n);
int x=rng();
if (x&1) {
for (int i=0; i<100; ++i) {
int f=receive(), s=receive();
if (f==s) {
if (f==0) return {1,2};
else return {2,3};
}
}
} else {
for (int i=0; i<100; ++i) {
int f=receive(), s=receive();
if (f==s) {
if (f==1) return {1,2};
else return {2,3};
}
}
}
x=rng();
if (x&1) return {1,3};
else return {2,3};
}
void encode(int n, int x) {
mt19937 rng(n);
int p=rng();
if (p&1) {
for (int i=0; i<100; ++i) {
if (x<=2) send(0);
else send(1);
if (x<=2) send(0);
else send(1);
}
} else {
for (int i=0; i<100; ++i) {
if (x>=2) send(0);
else send(1);
if (x>=2) send(0);
else send(1);
}
}
}