Submission #850358

#TimeUsernameProblemLanguageResultExecution timeMemory
850358MinaRagy06Flight to the Ford (BOI22_communication)C++17
0 / 100
2 ms588 KiB
#include <bits/stdc++.h> #include "communication.h" #ifdef MINA #include "grader.cpp" #endif using namespace std; int ask(int x) { int ret = send(x); return ret; } const int m = 125; void encode(int n, int x) { mt19937 rng(2006); for (int i = 0; i < 2; i++) { for (int j = 0; j < m; j++) { ask((rng() & 1) ^ ((x >> i) & 1)); } while (ask(1) != 1); } } pair<int, int> decode(int n) { int a[2][m]{}; for (int i = 0; i < 2; i++) { for (int j = 0; j < m; j++) { a[i][j] = receive(); } while (receive() != 1); } int ans = 0; mt19937 rng(2006); for (int i = 0; i < 2; i++) { int v[m]; for (int j = 0; j < m; j++) { v[j] = (rng() & 1); } int lst = 0, bit = 0; for (int j = 0; j < m; j++) { if (a[i][j] != v[j]) { if (lst) { bit = 1; break; } lst = 1; } else { lst = 0; } } ans |= bit << i; } return {ans, ans}; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...