#include "communication.h"
#include <bits/stdc++.h>
using namespace std;
void encode(int N, int X) {
vector<int> signals(250, 0);
if (X == 1) {
signals[0] = 0;
signals[1] = 0;
signals[2] = 0;
} else if (X == 2) {
signals[0] = 0;
signals[1] = 1;
signals[2] = 0;
} else if (X == 3) {
signals[0] = 1;
signals[1] = 0;
signals[2] = 0;
}
for (size_t i = 0; i < 3; ++i) {
send(signals[i]);
}
}
pair<int, int> decode(int N) {
vector<int> receivedSignals(3);
for (size_t i = 0; i < 3; ++i) {
receivedSignals[i] = receive();
}
if (receivedSignals[0] == 0 && receivedSignals[1] == 0) {
return {1, 2};
} else if (receivedSignals[0] == 0 && receivedSignals[1] == 1) {
return {2, 3};
} else if (receivedSignals[0] == 1 && receivedSignals[1] == 0) {
return {3, 1};
} else {
return {1, 1};
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
332 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
332 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |