#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"
vector<int> V = {1,1,0,0,1,0,0,0,0,0,1,1,1,1,1,1,1,0,1,0,1,0,0,1,0,0,1,0,0,1,1,0,1,0,1,0,1,1,1,0,1,1,0,1,1,0,1,1,1,0,1,0,0,1,1,1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,1,0,1,1,0,0,0,0,0,0,1,0,0,1,0,1,1,0,0,0,1,1};
//bool aux[250];
/*
vector<int> v;
int send(int x){
cout<<x<<" SENDED"<<endl;
int c;
cin >> c;
v.pb(c);
return c;
}
int P = 0;
int receive(){
cout<<"SEND ME"<<endl;
int c;
return v[P++];
}
*/
void encode(int N, int X){
srand(N);
int pos = 0;
while(pos < 30){
int bit = 0;
if(X & (1<<pos)) bit = 1;
int c = rand() + pos;
int nxt = V[c%100];
if(c % 4){
int r = send(nxt);
if(r != nxt){
send(bit);
++pos;
}
}
else{
int r1 = send(bit);
int r2 = send(bit);
int r3 = send(bit);
int r4 = send(bit);
if(r1 == r2 || r2 == r3 || r3 == r4){
++pos;
}
}
}
}
std::pair<int, int> decode(int N){
srand(N);
int pos = 0;
int X = 0;
int CC = 0;
while(pos < 30){
int c = rand() + pos;
int nxt = V[c%100];
if(c % 4){
++C;
if(C > 250)cout<<2/0<<endl;
int r = receive();
if(r != nxt){
++C;
if(C > 250)cout<<2/0<<endl;
int bit = receive();
if(bit == 1) X |= (1<<pos);
++pos;
}
}
else{
++C;
if(C > 250)cout<<2/0<<endl;
int r1 = receive();
++C;
if(C > 250)cout<<2/0<<endl;
int r2 = receive();
++C;
if(C > 250)cout<<2/0<<endl;
int r3 = receive();
++C;
if(C > 250)cout<<2/0<<endl;
int r4 = receive();
if(r1 == r2){
if(r1 == 1) X |= (1<<pos);
++pos;
}
else if(r2 == r3){
if(r2 == 1) X |= (1<<pos);
++pos;
}
else if(r3 == r4){
if(r3 == 1) X |= (1<<pos);
++pos;
}
}
}
return {X, 1};
}/*
int main(){
encode(10, 1);
decode(10);
}
*/
Compilation message
communication.cpp: In function 'std::pair<int, int> decode(int)':
communication.cpp:85:6: error: 'C' was not declared in this scope
85 | ++C;
| ^
communication.cpp:86:22: warning: division by zero [-Wdiv-by-zero]
86 | if(C > 250)cout<<2/0<<endl;
| ~^~
communication.cpp:92:23: warning: division by zero [-Wdiv-by-zero]
92 | if(C > 250)cout<<2/0<<endl;
| ~^~
communication.cpp:101:6: error: 'C' was not declared in this scope
101 | ++C;
| ^
communication.cpp:102:22: warning: division by zero [-Wdiv-by-zero]
102 | if(C > 250)cout<<2/0<<endl;
| ~^~
communication.cpp:107:22: warning: division by zero [-Wdiv-by-zero]
107 | if(C > 250)cout<<2/0<<endl;
| ~^~
communication.cpp:112:22: warning: division by zero [-Wdiv-by-zero]
112 | if(C > 250)cout<<2/0<<endl;
| ~^~
communication.cpp:117:22: warning: division by zero [-Wdiv-by-zero]
117 | if(C > 250)cout<<2/0<<endl;
| ~^~
communication.cpp:77:6: warning: unused variable 'CC' [-Wunused-variable]
77 | int CC = 0;
| ^~