This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "grader.h"
#include "encoder.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 20;
const int maxk = 40;
vector<int> adj[maxn];
int dist[maxk][maxn];
int n, h;
void bfs(int s) {
for (int i = 1; i <= n; i++) {
dist[s][i] = -1;
}
dist[s][s] = 0;
deque<int> q;
q.push_back(s);
while (!q.empty()) {
int u = q.front();
q.pop_front();
for (auto v: adj[u]) {
if (dist[s][v] == -1) {
dist[s][v] = dist[s][u] + 1;
q.push_back(v);
}
}
}
}
void encode(int _n, int _h, int m, int *x, int *y){
n = _n;
h = _h;
for (int i = 0; i < m; i++) {
int u = x[i] + 1;
int v = y[i] + 1;
adj[u].push_back(v);
adj[v].push_back(u);
}
for (int i = 1; i <= h; i++) {
bfs(i);
}
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= n; j++) {
for (int k = 0; k < 10; k++) {
encode_bit((dist[i][j] >> k) & 1);
}
}
}
}
#include "grader.h"
#include "decoder.h"
void decode(int n, int h) {
for (int i = 0; i < h; i++) {
for (int j = 0; j < n; j++) {
int dist = 0;
for (int k = 0; k < 10; k++) {
dist |= decode_bit() << k;
}
hops(i, j, dist);
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |