#include <map>
#include <vector>
#include <set>
#include <cmath>
#include "grader.h"
using namespace std;
int const MAXN=1000+10;
vector<int>nei[MAXN]={};
int dis[MAXN]={};
void bfs(int x)
{
dis[x]=0;
set<pair<int,int>>s;
s.insert({0,x});
while (s.size())
{
int z=(*begin(s)).second;
s.erase(*begin(s));
for (auto i:nei[z])
{
if (dis[i]>dis[z]+1)
{
s.erase({dis[i],i});
dis[i]=dis[z]+1;
s.insert({dis[i],i});
}
}
}
}
void qu(int x)
{
for (int i=0;i<=11;i++)
{
if ((1<<i)&x)
encode_bit(1);
else
encode_bit(0);
}
}
void encode(int N,int H,int P,int v1[1234567],int v2[1234567])
{
for (int i=0;i<P;i++)
{
int a=v1[i],b=v2[i];
qu((a&b));qu((a|b));qu((a^b));
}
for (int i=0;i<=11;i++)
encode_bit(1);
}
int q()
{
int x=0;
for (int i=0;i<=11;i++)
{
if (decode_bit())
x+=(1<<i);
}
return x;
}
void decode(int N,int H)
{
while (1)
{
int an=q();
if (an==4095)
break;
int o=q(),xo=q();
for (int i=0;i<N;i++)
{
for (int j=i+1;j<N;j++)
{
if ((i&j)==an&&(i|j)==o&&(i^j)==xo)
{
// printf("%d %d\n",i,j);
nei[i].push_back(j);
nei[j].push_back(i);
}
}
}
}
for (int i=0;i<H;i++)
{
for (int j=0;j<N;j++)
dis[j]=1e4;
bfs(i);
for (int j=0;j<N;j++)
hops(i,j,dis[j]);
}
}
Compilation message
/usr/bin/ld: /tmp/ccFZJZNc.o: in function `q()':
encoder.cpp:(.text+0x399): undefined reference to `decode_bit()'
/usr/bin/ld: /tmp/ccFZJZNc.o: in function `decode(int, int)':
encoder.cpp:(.text+0x631): undefined reference to `decode_bit()'
/usr/bin/ld: encoder.cpp:(.text+0x671): undefined reference to `decode_bit()'
/usr/bin/ld: encoder.cpp:(.text+0x6a1): undefined reference to `decode_bit()'
/usr/bin/ld: encoder.cpp:(.text+0x80a): undefined reference to `hops(int, int, int)'
collect2: error: ld returned 1 exit status
/usr/bin/ld: /tmp/ccjYEj3Y.o: in function `main':
grader_decoder.c:(.text.startup+0x126): undefined reference to `decode(int, int)'
collect2: error: ld returned 1 exit status