Submission #1099073

#TimeUsernameProblemLanguageResultExecution timeMemory
1099073LIAFlight to the Ford (BOI22_communication)C++17
0 / 100
7 ms352 KiB
#include "communication.h" void encode(int N, int X) { if (X == 1) { send(0); send(0); } else if (X == 2) { send(0); send(1); } else if (X == 3) { send(1); send(0); } send(0); } std::pair<int, int> decode(int N) { int signals[4]; for (int i = 0; i < 4; ++i) { signals[i] = receive(); } std::pair<int, int> result = {0, 0}; bool foundMessage1 = false; bool foundMessage2 = false; bool foundMessage3 = false; if (signals[0] == 0 && signals[1] == 0) { foundMessage1 = true; } if (signals[0] == 0 && signals[1] == 1) { foundMessage2 = true; } if (signals[0] == 1 && signals[1] == 0) { foundMessage3 = true; } if (foundMessage1) { result.first = 1; result.second = 1; } if (foundMessage2) { result.first = 2; result.second = 2; } if (foundMessage3) { if (result.first == 0) { result.first = 3; result.second = 3; } else { result.second = 3; } } if (result.first == 0) { return {1, 1}; } return result; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...