#include "grader.h"
#include "encoder.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int n;
int par[maxn];
int d[36][maxn];
vector <int> adj[maxn];
void bfs(int rt, bool keep)
{
queue<int> q;
fill_n(d[rt],n,-1);
d[rt][rt] = 0;
q.push(rt);
if (keep) par[rt] = rt;
while (!q.empty())
{
int u=q.front(); q.pop();
for (int v:adj[u])
if (d[rt][v] == -1)
{
d[rt][v] = d[rt][u] + 1;
if (keep) par[v] = u;
q.push(v);
}
}
}
inline bool checkbit(int i, int j)
{
return i>>j&1;
}
void encode(int nv, int nh, int ne, int *v1, int *v2){
n=nv;
for (int i=0; i<n; i++) adj[i].clear();
for (int i=0; i<ne; i++)
{
int u=v1[i]; int v=v2[i];
adj[u].push_back(v);
adj[v].push_back(u);
}
for (int i=0; i<nh; i++) bfs(i,(i==0));
for (int i=0; i<n; i++)
for (int j=0; j<10; j++)
encode_bit(checkbit(par[i],j));
par[n]=par[n+1]=par[n+2]=0;
for (int rt=1; rt<nh; rt++)
for (int i=1; i<n; i+=3)
{
int u,v;
u=i; v=par[i];
int t1 = (d[rt][u]==d[rt][v])?0:((d[rt][u]>d[rt][v])?1:2);
u=i+1; v=par[i+1];
int t2 = (d[rt][u]==d[rt][v])?0:((d[rt][u]>d[rt][v])?1:2);
u=i+2; v=par[i+2];
int t3 = (d[rt][u]==d[rt][v])?0:((d[rt][u]>d[rt][v])?1:2);
int T = t1+t2*3+t3*9;
for (int z=0; z<=5; z++) encode_bit(checkbit(T,z));
}
}
Compilation message
/usr/bin/ld: /tmp/ccIudn0x.o: in function `main':
grader_decoder.c:(.text.startup+0x126): undefined reference to `decode(int, int)'
collect2: error: ld returned 1 exit status