Submission #668193

#TimeUsernameProblemLanguageResultExecution timeMemory
668193fatemetmhrFlight to the Ford (BOI22_communication)C++17
74 / 100
3316 ms2092 KiB
// Willkommen! hier ist der Ort, an dem du sterben wirst :) #include"communication.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define all(x) x.begin(), x.end() #define pb push_back #define fi first #define se second const int maxn5 = 3e5 + 10; const ll inf = 1e18; const int lg = 30; void encode(int n, int x){ int g = 0; for(int i = 1; i < lg; i++){ int a1 = send((x >> g)&1); int b1 = send((x >> i)&1); int b2 = send((x >> i)&1); int a2 = send((x >> g)&1); if(b1 == b2) continue; if(a1 == a2) g = i; } } pair<int, int> decode(int N){ int a = 0, b = 1, g = 0; for(int i = 1; i < lg; i++){ int a1 = receive(); int b1 = receive(); int b2 = receive(); int a2 = receive(); if(b1 == b2){ a ^= (b1 << i); b ^= (b1 << i); continue; } if(a1 == a2){ if(((a >> g)&1) != a1) a = b; else b = a; a ^= (1 << i); g = i; continue; } if(((a >> g)&1) != a1) swap(a, b); a |= (b2 << i); b |= (b1 << i); } a = max(a, 1); a = min(a, N); b = max(b, 1); b = min(b, N); return {a, b}; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...