Submission #813087

#TimeUsernameProblemLanguageResultExecution timeMemory
813087Theo830Flight to the Ford (BOI22_communication)C++17
15 / 100
43 ms1876 KiB
#include"communication.h" #include <bits/stdc++.h> using namespace std; void encode(int n, int x){ vector<int>arr; for(int j = 1;j >= 0;j--){ if(x & (1<<j)){ arr.push_back(1); } else{ arr.push_back(0); } } send(arr[0]); send(arr[1]); send(arr[1]); send(arr[0]); } pair<int, int> decode(int n){ int a = 0,b = 0; vector<int>ex; for(int i = 0;i < 4;i++){ ex.push_back(receive()); } if(ex[1] == ex[2]){ a = b = ex[1]; b += 2; } else if(ex[0] == ex[3]){ a = b = 2 * ex[0]; b++; } else{ a = ex[0] * 2 + ex[2]; b = ex[3] * 2 + ex[1]; } a = max(1,a); b = max(1,b); b = min(n,b); a = min(n,a); return {a,b}; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...