#include"communication.h"
#include <bits/stdc++.h>
#define IO_OP ios::sync_with_stdio(0), cin.tie(0)
#define F first
#define S second
#define V vector
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;
const int INF = 1e9 + 7;
int aux[] = {0b0000, 0b1001, 0b0110};
void encode(int n, int x) {
for(int i = 0; i < 4; i++)
send(aux[x - 1] >> i & 1);
}
pi decode(int n) {
int x = 0;
for(int i = 0; i < 4; i++)
x |= receive() << i;
vi ans;
for(int k = 0; k < 3; k++)
if(x == aux[k])
ans.PB(k + 1);
for(int i = 0; i < 4; i++) {
int y = x ^ (1 << i);
for(int k = 0; k < 3; k++)
if(y == aux[k])
ans.PB(k + 1);
for(int j = 0; j < i - 1; j++) {
int z = y ^ (1 << j);
for(int k = 0; k < 3; k++)
if(z == aux[k])
ans.PB(k + 1);
}
}
while(SZ(ans) < 2) ans.PB(1);
return {ans[0], ans[1]};
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1796 KB |
Output is correct |
2 |
Correct |
11 ms |
1800 KB |
Output is correct |
3 |
Correct |
17 ms |
1700 KB |
Output is correct |
4 |
Correct |
13 ms |
1748 KB |
Output is correct |
5 |
Correct |
12 ms |
1680 KB |
Output is correct |
6 |
Correct |
23 ms |
1776 KB |
Output is correct |
7 |
Correct |
50 ms |
1684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
288 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |