This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Willkommen! hier ist der Ort, an dem du sterben wirst :) so aufregend! nein?
#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 a = 0, b = 1, g = 0, keep = -1;
for(int i = 1; i < lg; i++){
if(max(a, b) > n){
a = b = min(a, b);
keep = -1;
g = i;
a ^= (1 << g);
continue;
}
int a1 = (keep == -1 ? send((x >> g)&1) : keep);
int b1 = send((x >> i)&1);
int b2 = send((x >> i)&1);
int a2 = send((x >> g)&1);
keep = a2;
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;
keep = -1;
}
if(((a >> g)&1) != a1)
swap(a, b);
a |= (b2 << i);
b |= (b1 << i);
}
}
pair<int, int> decode(int N){
int a = 0, b = 1, g = 0, keep = -1;
for(int i = 1; i < lg; i++){
if(max(a, b) > N){
a = b = min(a, b);
keep = -1;
g = i;
a ^= (1 << g);
continue;
}
int a1 = (keep == -1 ? receive() : keep);
int b1 = receive();
int b2 = receive();
int a2 = receive();
keep = a2;
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;
keep = -1;
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |