Submission #666600

#TimeUsernameProblemLanguageResultExecution timeMemory
666600mychecksedadFlight to the Ford (BOI22_communication)C++17
0 / 100
9 ms252 KiB
#include <utility> #include <bits/stdc++.h> using namespace std; /** * use this function in encode when you want to send a certain signal * (it might come out wrong, and the return value tells you which signal * was actually sent) */ int send(int); /** * use this function in decode; it returns the next signal that was actually * sent during the corresponding call of encode */ int receive(); /** * implement these two functions yourself */ void encode(int N, int X){ if(X == 1){ send(0); send(0); send(0); send(0); } if(X == 2){ send(0); send(1); send(1); send(0); } if(X == 3){ send(1); send(1); send(1); send(1); } } pair<int, int> decode(int N) { int a = 0, b = 0, x = 0; int y[3] = {0, 6, 15}; for(int j = 0; j < 4; ++j) x += receive() * (1<<j); map<int, bool> m; auto corrupt = [&](int n){ m[n^1] = 1; m[n^2] = 1; m[n^4] = 1; m[n^8] = 1; m[n^5] = 1; m[n^9] = 1; m[n^10] = 1; m[n] = 1; }; for(int j = 0; j < 3; ++j){ bool ok = 1; corrupt(y[j]); if(!m[x]){ continue; } m.clear(); for(int i = 0; i < 3; ++i){ if(i==j) continue; corrupt(y[i]); if(!m[x]){ ok = 0; continue; } m.clear(); if(ok){ a = j + 1; b = i + 1; return {a, b}; } } return {j + 1, j + 1}; } return {1, 3}; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...