#include "grader.h"
#include "encoder.h"
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
void encode(int n, int h, vector<int>p, vector<int>a, vector<int>b) {
vector<pair<int,int>>V[n];
int uzyte[a.size()], odl[n];
rep(i, a.size()) {
uzyte[i]=0;
V[a[i]].pb({b[i], i});
V[b[i]].pb({a[i], i});
}
rep(i, h) {
rep(j, n) odl[j]=1000000007;
queue<int>q;
q.push(p[i]);
odl[p[i]]=0;
while(!q.empty()) {
int p=q.front(); q.pop();
for(auto j : V[p]) if(odl[j.st]>odl[p]+1) {
odl[j.st]=odl[p]+1;
q.push(j.st);
uzyte[j.nd]=1;
}
}
}
vector<int>T[n];
rep(i, a.size()) if(uzyte[i]) {
T[a[i]].pb(b[i]);
T[b[i]].pb(a[i]);
}
rep(i, h) rep(j, 10) encode_bit(p[i]&(1<<j));
rep(i, n) {
rep(j, 10) encode_bit(T[i].size()&(1<<j));
for(auto j : T[i]) {
rep(l, 10) encode_bit(j&(1<<l));
}
}
}
#include "grader.h"
#include "decoder.h"
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
void decode(int n, int h) {
vector<int>p, V[n];
rep(i, h) {
int a=0;
rep(j, 10) a+=decode_bit()*(1<<j);
p.pb(a);
}
rep(i, n) {
int a=0;
rep(j, 10) a+=decode_bit()*(1<<j);
rep(j, a) {
int x=0;
rep(l, 10) x+=decode_bit()*(1<<l);
V[i].pb(x);
}
}
for(auto i : p) {
int odl[n];
rep(j, n) odl[j]=1000000007;
queue<int>q;
q.push(i);
odl[i]=0;
while(!q.empty()) {
int p=q.front(); q.pop();
for(auto j : V[p]) if(odl[j]>odl[p]+1) {
odl[j]=odl[p]+1;
q.push(j);
}
}
rep(j, n) hops(i, j, odl[j]);
}
}
Compilation message
encoder.cpp: In function 'void encode(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
encoder.cpp:6:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
6 | #define rep(a, b) for(int a = 0; a < (b); ++a)
| ^
encoder.cpp:14:2: note: in expansion of macro 'rep'
14 | rep(i, a.size()) {
| ^~~
encoder.cpp:6:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
6 | #define rep(a, b) for(int a = 0; a < (b); ++a)
| ^
encoder.cpp:34:2: note: in expansion of macro 'rep'
34 | rep(i, a.size()) if(uzyte[i]) {
| ^~~
/usr/bin/ld: /tmp/ccBwUU1C.o: in function `main':
grader_encoder.c:(.text.startup+0x122): undefined reference to `encode(int, int, int, int*, int*)'
collect2: error: ld returned 1 exit status