#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]};
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1684 KB |
Output is correct |
2 |
Correct |
13 ms |
1684 KB |
Output is correct |
3 |
Correct |
14 ms |
1820 KB |
Output is correct |
4 |
Correct |
5 ms |
1736 KB |
Output is correct |
5 |
Correct |
12 ms |
1776 KB |
Output is correct |
6 |
Correct |
29 ms |
1756 KB |
Output is correct |
7 |
Correct |
41 ms |
1672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
328 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |