#include <communication.h>
#include <bits/stdc++.h>
using namespace std;
void encode(int n, int x) {
if (x == 1) {
send(1);
send(1);
send(1);
send(1);
} else if (x == 2) {
send(0);
send(0);
send(0);
send(0);
} else {
send(0);
send(1);
send(1);
send(0);
}
}
pair<int, int> decode(int n) {
vector<bool> canBe (3, true);
vector<int> bits {};
for (int i = 0; i < 4; i++)
bits.push_back(receive());
bool hasConseq = false;
for (int i = 0; i + 1 < 4; i++) {
if (bits[i] == 0 && bits[i + 1] == 0) {
canBe[0] = false;
hasConseq = true;
}
if (bits[i] == 1 && bits[i + 1] == 1) {
canBe[1] = false;
hasConseq = true;
}
}
if (!hasConseq)
canBe[2] = false;
vector<int> ans {};
for (int i = 0; i < 3; i++)
if (canBe[i])
ans.push_back(i + 1);
//assert((int)ans.size() <= 2);
if ((int)ans.size() == 1)
return {ans[0], ans[0]};
return {ans[0], ans[1]};
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
1632 KB |
Output is correct |
2 |
Correct |
11 ms |
1840 KB |
Output is correct |
3 |
Correct |
13 ms |
1684 KB |
Output is correct |
4 |
Correct |
11 ms |
1796 KB |
Output is correct |
5 |
Correct |
13 ms |
1812 KB |
Output is correct |
6 |
Correct |
18 ms |
1848 KB |
Output is correct |
7 |
Correct |
36 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
19 ms |
200 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |