Submission #582155

#TimeUsernameProblemLanguageResultExecution timeMemory
582155KoDFlight to the Ford (BOI22_communication)C++17
15 / 100
44 ms1868 KiB
#include "communication.h" #include <bits/stdc++.h> using std::vector; int A[4][4] = { {-1, -1, -1, -1}, {0, 0, 0, 0}, {0, 1, 1, 0}, {1, 1, 1, 1} }; void encode(int N, int X) { for (int i = 0; i < 4; ++i) { send(A[X][i]); } } std::pair<int, int> decode(int N) { vector<int> vec; for (int i = 0; i < 4; ++i) { vec.push_back(receive()); } for (int i = 1; i <= 3; ++i) { bool f = false; for (const int ch : {0, 1, 2, 4, 8, 5, 9, 10}) { vector<int> a(4); for (int j = 0; j < 4; ++j) { a[j] = A[i][j] ^ (ch >> j & 1); } if (a == vec) { f = true; break; } } if (!f) { if (i == 1) return {2, 3}; if (i == 2) return {1, 3}; if (i == 3) return {1, 2}; } } return {-1, -1}; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...