#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define st first
#define nd second
#define pb push_back
#define pq priority_queue
#define all(x) begin(x), end(x)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#include "communication.h"
bool aux[250];
void encode(int N, int X) {
srand(N);
int pos = 0;
while(pos < 30){
int r_bit = X&(1<<pos);
if(r_bit != 0) r_bit = 1;
int nxt = 2;
if(rand()%2) nxt = 3;
int t = send(1);
if(t == 1){
bool ok = true;
fr(i, 0, nxt){
int c = send(r_bit);
ok |= (c == r_bit);
}
if(ok) ++pos;
}
else{
send(r_bit);
fr(i, 0, nxt-1) send(0);
++pos;
}
}
}
std::pair<int, int> decode(int N){
srand(N);
int pos = 0;
int X = 0;
while(pos < 30){
int nxt = 2;
if(rand()%2) nxt = 3;
int t = receive();
if(t == 1){
int sum = 0;
fr(i, 0, nxt){
sum += receive();
}
if(sum == 0) ++pos;
else if(sum == nxt){
X |= (1<<pos);
++pos;
}
}
else{
if(receive() == 1) X |= (1<<pos);
++pos;
}
}
return X;
}
Compilation message
communication.cpp: In function 'std::pair<int, int> decode(int)':
communication.cpp:80:9: error: could not convert 'X' from 'int' to 'std::pair<int, int>'
80 | return X;
| ^
| |
| int