Submission #580153

#TimeUsernameProblemLanguageResultExecution timeMemory
580153wiwihoFlight to the Ford (BOI22_communication)C++17
15 / 100
45 ms1808 KiB
#include"communication.h" #include <bits/stdc++.h> #define iter(a) a.begin(), a.end() #define lsort(a) sort(iter(a)) #define gsort(a) sort(iter(a), greater<>()) #define eb emplace_back #define ef emplace_front #define pob pop_back() #define pof pop_front() #define mp make_pair #define F first #define S second #define uni(a) a.resize(unique(iter(a)) - a.begin()) #define printv(a, b) { \ for(auto pv : a) b << pv << " "; \ b << "\n"; \ } using namespace std; typedef long long ll; using pii = pair<int, int>; using pll = pair<ll, ll>; template<typename A, typename B> ostream& operator<<(ostream& o, pair<A, B> p){ return o << '(' << p.F << ',' << p.S << ')'; } const int SZ = 4; void encode(int N, int X) { auto owo = [&](int t){ for(int i = 0; i < SZ; i++){ if(1 << i & t) send(1); else send(0); } }; if(X == 1) owo(0b0000); if(X == 2) owo(0b0110); if(X == 3) owo(0b1001); } pii decode(int N) { int X = 0; for(int i = 0; i < SZ; i++){ if(receive()) X |= 1 << i; } vector<int> ans; int n = 1 << SZ; for(int i = 0; i < n; i++){ bool ok = true; for(int j = 0; j + 1 < SZ; j++){ if((1 << j & i) && (1 << (j + 1) & i)) ok = false; } if(!ok) continue; int tmp = X ^ i; if(tmp == 0b0000) ans.eb(1); else if(tmp == 0b0110) ans.eb(2); else if(tmp == 0b1001) ans.eb(3); } while(ans.size() < 2) ans.eb(1); return {ans[0], ans[1]}; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...