This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#include "communication.h"
void encode(int N, int X){
// Solve for N <= 3
if (X == 1){
int c1 = send(0);
if (c1 == 0){
send(0);
// message = 00 / 01
}
else{
send(1);
send(0);
// message = 110 / 111
}
}
else if (X == 2){
int c1 = send(1);
if (c1 == 0){
send(0);
// message = 00
}
else{
int c2 = send(0);
if (c2 == 0){
send(0);
// message = 100 / 101
}
else{
send(0);
// message = 110
}
}
}
else{
int c1 = send(1);
if (c1 == 0){
send(1);
// message = 01
}
else{
int c2 = send(0);
if (c2 == 0){
send(0);
// message = 100 / 101
}
else{
send(1);
// message = 111
}
}
}
}
pair<int, int> decode(int N){
int c1 = receive();
if (c1 == 0){
int c2 = receive();
if (c2 == 0) return {1, 2};
else return {1, 3};
}
else{
int c2 = receive();
int c3 = receive();
if (c2 == 0) return {2, 3};
if (c3 == 0) return {1, 2};
else return {1, 3};
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |