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);
bool lo = (X >> 0) & 1;
bool hi = (X >> 1) & 3;
int sent = 0;
do sent++; while (send(lo) != lo) ;
while (sent++ < 4 && send(lo) == lo) ;
while (sent++ < 4) send(hi);
}
constexpr int LEN = 4;
pair<int, int> starting_guesses(vector<int> packet) {
if (packet[0] == packet[1] || packet[1] == packet[2])
return {packet[1], packet[1] + 2};
return {packet[0] + 2 * packet[2], packet[1] + 2 * packet[3]};
}
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), min(N, guess_2)};
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |