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 std::vector;
int A[4][4] = {
{-1, -1, -1, -1},
{0, 0, 0, 0},
{0, 1, 1, 0},
{1, 1, 1, 1}
};
void encode(int N, int X) {
for (int i = 0; i < 4; ++i) {
send(A[X][i]);
}
}
std::pair<int, int> decode(int N) {
vector<int> vec;
for (int i = 0; i < 4; ++i) {
vec.push_back(receive());
}
for (int i = 1; i <= 3; ++i) {
bool f = false;
for (const int ch : {0, 1, 2, 4, 8, 5, 9, 10}) {
vector<int> a(4);
for (int j = 0; j < 4; ++j) {
a[j] = A[i][j] ^ (ch >> j & 1);
}
if (a == vec) {
f = true;
break;
}
}
if (!f) {
if (i == 1) return {2, 3};
if (i == 2) return {1, 3};
if (i == 3) return {1, 2};
}
}
return {-1, -1};
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |