#include"communication.h"
#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
//
// --- Sample implementation for the task communication ---
//
// To compile this program with the sample grader, place:
// communication.h communication_sample.cpp sample_grader.cpp
// in a single folder, then open the terminal in this directory (right-click onto an empty spot in the directory,
// left click on "Open in terminal") and enter e.g.:
// g++ -std=c++17 communication_sample.cpp sample_grader.cpp
// in this folder. This will create a file a.out in the current directory which you can execute from the terminal
// as ./a.out
// See task statement or sample_grader.cpp for the input specification
//
void encode(int N, int X) {
int r;
if(X == 1) {
send(1);
send(0);
send(0);
}
if(x == 2) {
send(0);
send(1);
send(0);
}
if(x == 3) {
r = send(0);
if(r == 0) send(1);
else send(0);
send(1);
}
}
ii decode(int N) {
int a = receive();
int b = receive();
int c = receive();
if(a == 0 && b == 0 && c == 0) return {1, 2};
if(a == 0 && b == 0 && c == 1) return {1, 3};
if(a == 0 && b == 1 && c == 0) return {2, 3};
if(a == 0 && b == 1 && c == 1) return {2, 3};
if(a == 1 && b == 0 && c == 0) return {1, 3};
if(a == 1 && b == 0 && c == 1) return {1, 3};
if(a == 1 && b == 1 && c == 0) return {1, 2};
if(a == 1 && b == 1 && c == 1) return {2, 2};
}
Compilation message
communication.cpp: In function 'void encode(int, int)':
communication.cpp:5:11: error: 'first' was not declared in this scope
5 | #define x first
| ^~~~~
communication.cpp:32:5: note: in expansion of macro 'x'
32 | if(x == 2) {
| ^
communication.cpp:5:11: error: 'first' was not declared in this scope
5 | #define x first
| ^~~~~
communication.cpp:37:5: note: in expansion of macro 'x'
37 | if(x == 3) {
| ^
communication.cpp: In function 'ii decode(int)':
communication.cpp:57:1: warning: control reaches end of non-void function [-Wreturn-type]
57 | }
| ^