// 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;
int keep = -1;
for(int i = 1; i < lg; i++){
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)
continue;
if(a1 == a2){
g = i;
keep = -1;
}
}
}
pair<int, int> decode(int N){
int a = 0, b = 1, g = 0, keep = -1;
for(int i = 1; i < lg; i++){
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 |
1 |
Correct |
54 ms |
1788 KB |
Output is correct |
2 |
Correct |
100 ms |
1720 KB |
Output is correct |
3 |
Correct |
161 ms |
1776 KB |
Output is correct |
4 |
Correct |
84 ms |
1684 KB |
Output is correct |
5 |
Correct |
90 ms |
1700 KB |
Output is correct |
6 |
Correct |
263 ms |
1732 KB |
Output is correct |
7 |
Correct |
494 ms |
1744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
571 ms |
1704 KB |
Output is partially correct |
2 |
Partially correct |
296 ms |
1884 KB |
Output is partially correct |
3 |
Partially correct |
383 ms |
1664 KB |
Output is partially correct |
4 |
Partially correct |
744 ms |
1832 KB |
Output is partially correct |
5 |
Partially correct |
525 ms |
1720 KB |
Output is partially correct |
6 |
Correct |
458 ms |
1688 KB |
Output is correct |
7 |
Correct |
1553 ms |
1896 KB |
Output is correct |
8 |
Correct |
2643 ms |
1940 KB |
Output is correct |
9 |
Correct |
2381 ms |
1908 KB |
Output is correct |
10 |
Correct |
2203 ms |
1812 KB |
Output is correct |
11 |
Correct |
2318 ms |
1800 KB |
Output is correct |
12 |
Correct |
2239 ms |
1824 KB |
Output is correct |
13 |
Correct |
2131 ms |
1864 KB |
Output is correct |
14 |
Correct |
2288 ms |
1884 KB |
Output is correct |
15 |
Correct |
1224 ms |
1800 KB |
Output is correct |
16 |
Correct |
2554 ms |
1832 KB |
Output is correct |
17 |
Correct |
772 ms |
1744 KB |
Output is correct |
18 |
Correct |
592 ms |
1756 KB |
Output is correct |
19 |
Correct |
761 ms |
1848 KB |
Output is correct |
20 |
Correct |
612 ms |
1740 KB |
Output is correct |
21 |
Correct |
687 ms |
1808 KB |
Output is correct |
22 |
Correct |
622 ms |
1764 KB |
Output is correct |
23 |
Correct |
1091 ms |
1836 KB |
Output is correct |
24 |
Correct |
92 ms |
1668 KB |
Output is correct |
25 |
Correct |
95 ms |
1636 KB |
Output is correct |
26 |
Correct |
130 ms |
1708 KB |
Output is correct |
27 |
Correct |
72 ms |
1684 KB |
Output is correct |
28 |
Correct |
112 ms |
1680 KB |
Output is correct |
29 |
Correct |
206 ms |
1724 KB |
Output is correct |
30 |
Correct |
527 ms |
1680 KB |
Output is correct |