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 <bits/stdc++.h>
#include "communication.h"
using namespace std;
void encode(int N, int X) {
assert(N == 3);
switch (--X) {
case 0: send(0), send(0), send(0), send(0); break;
case 1: send(0), send(1), send(1), send(0); break;
case 2: send(1), send(0), send(0), send(1); break;
}
}
constexpr int LEN = 4;
pair<int, int> starting_guesses(vector<int> packet) {
int val = packet[0] | 2 * packet[1] | 4 * packet[2] | 8 * packet[3];
switch (val) {
case 0: return {0, 2};
case 1: return {0, 2};
case 2: return {0, 1};
case 3: return {1, 2};
case 4: return {0, 1};
case 5: return {0, 0};
case 6: return {1, 1};
case 7: return {1, 1};
case 8: return {0, 2};
case 9: return {0, 2};
case 10: return {0, 0};
case 11: return {2, 2};
case 12: return {1, 2};
case 13: return {2, 2};
case 14: return {1, 1};
case 15: return {1, 1};
}
}
pair<int, int> decode(int N) {
vector<int> message(LEN);
for (auto &x: message) x = receive();
auto [guess_1, guess_2] = starting_guesses(vector(message.end() - 4, message.end()));
return {min(N, guess_1 + 1), min(N, guess_2 + 1)};
}
Compilation message (stderr)
communication.cpp: In function 'std::pair<int, int> starting_guesses(std::vector<int>)':
communication.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
37 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |