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 "communication.h"
#include <bits/stdc++.h>
using namespace std;
void encode(int n, int x) {
assert(n == 3);
if (x == 1) send(0), send(0), send(0), send(0);
if (x == 2) send(0), send(1), send(1), send(0);
if (x == 3) send(1), send(1), send(1), send(1);
}
pair<int, int> decode(int n) {
assert(n == 3);
vector<int> V, cand;
vector<int> a[3] = {{0, 0, 0, 0}, {0, 1, 1, 0}, {1, 1, 1, 1}};
for (int i = 0; i < 4; i++) V.push_back(receive());
for (int i = 0; i < 3; i++) {
int lst = -2;
bool flag = 1;
for (int j = 0; j < 4; j++) if (V[j] ^ a[i][j]) {
if (lst == j - 1) flag = 0;
lst = j;
}
if (flag) cand.push_back(i + 1);
}
return {cand[0], cand[cand.size() == 1 ? 0 : 1]};
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |