#include <bits/stdc++.h>
#include "communication.h"
#ifdef MINA
#include "grader.cpp"
#endif
using namespace std;
int ask(int x) {
int ret = send(x);
cout << ret << '\n';
return ret;
}
const int m = 6;
void encode(int n, int x) {
mt19937 rng(2006);
for (int i = 0; i < 2; i++) {
for (int j = 0; j < m; j++) {
ask((rng() & 1) ^ ((x >> i) & 1));
}
while (ask(1) != 1);
}
}
pair<int, int> decode(int n) {
int a[2][m]{};
for (int i = 0; i < 2; i++) {
for (int j = 0; j < m; j++) {
a[i][j] = receive();
}
while (receive() != 1);
}
int ans = 0;
mt19937 rng(2006);
for (int i = 0; i < 2; i++) {
int v[m];
for (int j = 0; j < m; j++) {
v[j] = (rng() & 1);
}
int lst = 0, bit = 0;
for (int j = 0; j < m; j++) {
if (a[i][j] != v[j]) {
if (lst) {
bit = 1;
break;
}
lst = 1;
} else {
lst = 0;
}
}
ans |= bit << i;
}
cout << ans << '\n';
return {ans, ans};
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Security violation! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
420 KB |
Security violation! |
2 |
Halted |
0 ms |
0 KB |
- |