#include "communication.h"
#include <bits/stdc++.h>
using namespace std;
const int mask1 = 0b11101100010010110111101010000;
void sendbit(int bit) {
if (bit) {
for (int i = 0; i < 30; i++) {
send((mask1 >> i) & 1);
}
} else {
for (int i = 0; i < 30; i++) {
send(((mask1 >> i) & 1) ^ 1);
}
}
}
void encode(int N, int X) {
// N = 3
if (X == 2)
sendbit(1);
else
sendbit(0);
}
int recbit() {
int cnt[2];
cnt[0] = cnt[1] = 0;
for (int i = 0; i < 30; i++) {
int rec = receive();
if (((rec >> i) & 1) == ((mask1 >> i) & 1))
cnt[1]++;
else
cnt[0]++;
}
return cnt[0] > cnt[1] ? 0 : 1;
}
std::pair<int, int> decode(int N) { return {1, (recbit() ? 2 : 3)}; }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
200 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
94 ms |
200 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |