#include "communication.h"
#include <iostream>
void encode(int N, int X) {
--X;
if (N > 3) return;
int position = 0;
int depth = 0;
while (depth < 2) {
int intent = 0;
if (position != (X + 2) % 3) intent = 1;
if (send(intent) == 0) {
++position;
position %= 3;
}
else ++depth;
}
// std::cerr << "Finish on position " << position << '\n';
}
std::pair<int, int> decode(int N) {
int position = 0;
int depth = 0;
while (depth < 2) {
if (receive() == 0) {
++position;
position %= 3;
}
else ++depth;
}
// std::cerr << "Finish on position " << position << '\n';
return { position + 1, (position + 2) % 3 + 1 };
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2788 KB |
Output is correct |
2 |
Correct |
9 ms |
3044 KB |
Output is correct |
3 |
Correct |
11 ms |
2956 KB |
Output is correct |
4 |
Correct |
13 ms |
3208 KB |
Output is correct |
5 |
Correct |
6 ms |
2760 KB |
Output is correct |
6 |
Correct |
14 ms |
3032 KB |
Output is correct |
7 |
Correct |
26 ms |
3104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
332 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |