#include <bits/stdc++.h>
using namespace std;
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include "communication.h"
void encode(int N, int X) {
if (X == 1) {
send(0);
send(1);
} else if (X == 2) {
send(1);
send(0);
} else if (X == 3) {
send(1);
send(1);
}
}
pair<int, int> decode(int N) {
int first_bit = receive();
int second_bit = receive();
if (first_bit == 0 && second_bit == 1) {
return {1, 1};
} else if (first_bit == 1 && second_bit == 0) {
return {2, 2};
} else if (first_bit == 1 && second_bit == 1) {
return {3, 3};
}
return {1, 2};
}
int main() {
int N, X;
if (scanf("%d %d", &N, &X) != 2 || X < 1 || X > N)
return 0;
encode(N, X);
auto r = decode(N);
if (r.first < 1 || r.first > N || r.second < 1 || r.second > N)
return 0;
if (r.first == X || r.second == X)
return 0;
else
return 1;
}
Compilation message
/usr/bin/ld: /tmp/ccThm9gc.o: in function `main':
interface.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccUPmtVc.o:communication.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status