Submission #1104348

#TimeUsernameProblemLanguageResultExecution timeMemory
1104348fve5Flight to the Ford (BOI22_communication)C++17
0 / 100
4 ms584 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...