#include "grader.h"
#include "encoder.h"
#include <bits/stdc++.h>
using namespace std;
void encode(int nv, int nh, int ne, int *v1, int *v2) {
vector<vector<int>> g(nv);
for (int i = 0; i < ne; i++) {
g[v1[i]].push_back(v2[i]);
g[v2[i]].push_back(v1[i]);
}
vector<int> par(nv, -1);
vector<bool> was(nv);
function<void(int, int)> Dfs = [&](int v, int pv) {
par[v] = pv;
was[v] = true;
for (int u : g[v]) {
if (was[u]) {
continue;
}
Dfs(u, v);
}
};
Dfs(0, 0);
for (int v = 0; v < nv; v++) {
for (int b = 0; b < 10; b++) {
encode_bit(par[v] >> b & 1);
}
}
for (int h = 0; h < nh; h++) {
vector<int> dist(nv, -1);
dist[h] = 0;
vector<int> que(1, h);
for (int b = 0; b < (int) que.size(); b++) {
int i = que[b];
for (int j : g[i]) {
if (dist[j] == -1) {
dist[j] = dist[i] + 1;
que.push_back(j);
}
}
}
for (int v = 0; v < nv; v++) {
if (dist[v] == dist[par[v]]) {
encode_bit(0);
encode_bit(0);
}
if (dist[v] == dist[par[v]] + 1) {
encode_bit(0);
encode_bit(1);
}
if (dist[v] == dist[par[v]] - 1) {
encode_bit(1);
encode_bit(0);
}
}
}
return;
}
#include "grader.h"
#include "decoder.h"
#include <bits/stdc++.h>
using namespace std;
void decode(int nv, int nh) {
vector<int> par(nv);
for (int v = 0; v < nv; v++) {
for (int b = 0; b < 10; b++) {
if (decode_bit()) {
par[v] += (1 << b);
}
}
}
vector<vector<int>> ch(nv);
for (int i = 1; i < nv; i++) {
ch[par[i]].push_back(i);
}
for (int h = 0; h < nh; h++) {
vector<int> d(nv);
for (int v = 0; v < nv; v++) {
int t = 0;
t += 2 * decode_bit();
t += decode_bit();
d[t] = (t == 0 ? 0 : (t == 1 ? 1 : -1));
}
vector<int> dist(nv, -1);
dist[h] = 0;
vector<int> que(1, h);
for (int b = 0; b < (int) que.size(); b++) {
int i = que[b];
for (int j : ch[i]) {
dist[j] = dist[i] + d[i];
que.push_back(j);
}
if (dist[par[i]] == -1) {
dist[par[i]] = dist[i] - d[i];
que.push_back(par[i]);
}
}
for (int v = 0; v < nv; v++) {
hops(h, v, dist[v]);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
147 ms |
16552 KB |
wrong parameter |
2 |
Incorrect |
2 ms |
11268 KB |
wrong parameter |
3 |
Runtime error |
236 ms |
262144 KB |
Execution killed with signal 9 |
4 |
Incorrect |
1 ms |
11268 KB |
wrong parameter |
5 |
Runtime error |
231 ms |
262144 KB |
Execution killed with signal 9 |
6 |
Runtime error |
255 ms |
262144 KB |
Execution killed with signal 9 |
7 |
Runtime error |
249 ms |
262144 KB |
Execution killed with signal 9 |
8 |
Runtime error |
239 ms |
262144 KB |
Execution killed with signal 9 |
9 |
Runtime error |
239 ms |
262144 KB |
Execution killed with signal 9 |
10 |
Runtime error |
232 ms |
262144 KB |
Execution killed with signal 9 |
11 |
Runtime error |
226 ms |
262144 KB |
Execution killed with signal 9 |
12 |
Runtime error |
232 ms |
262144 KB |
Execution killed with signal 9 |
13 |
Runtime error |
255 ms |
262144 KB |
Execution killed with signal 9 |
14 |
Runtime error |
226 ms |
262144 KB |
Execution killed with signal 9 |
15 |
Runtime error |
233 ms |
262144 KB |
Execution killed with signal 9 |
16 |
Runtime error |
249 ms |
262144 KB |
Execution killed with signal 9 |
17 |
Runtime error |
242 ms |
262144 KB |
Execution killed with signal 9 |
18 |
Runtime error |
256 ms |
262144 KB |
Execution killed with signal 9 |
19 |
Runtime error |
238 ms |
262144 KB |
Execution killed with signal 9 |
20 |
Runtime error |
246 ms |
262144 KB |
Execution killed with signal 9 |
21 |
Runtime error |
256 ms |
262144 KB |
Execution killed with signal 9 |
22 |
Runtime error |
246 ms |
262144 KB |
Execution killed with signal 9 |
23 |
Runtime error |
261 ms |
262144 KB |
Execution killed with signal 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
147 ms |
16552 KB |
wrong parameter |
2 |
Incorrect |
2 ms |
11268 KB |
wrong parameter |
3 |
Runtime error |
236 ms |
262144 KB |
Execution killed with signal 9 |
4 |
Incorrect |
1 ms |
11268 KB |
wrong parameter |
5 |
Runtime error |
231 ms |
262144 KB |
Execution killed with signal 9 |
6 |
Runtime error |
255 ms |
262144 KB |
Execution killed with signal 9 |
7 |
Runtime error |
249 ms |
262144 KB |
Execution killed with signal 9 |
8 |
Runtime error |
239 ms |
262144 KB |
Execution killed with signal 9 |
9 |
Runtime error |
239 ms |
262144 KB |
Execution killed with signal 9 |
10 |
Runtime error |
232 ms |
262144 KB |
Execution killed with signal 9 |
11 |
Runtime error |
226 ms |
262144 KB |
Execution killed with signal 9 |
12 |
Runtime error |
232 ms |
262144 KB |
Execution killed with signal 9 |
13 |
Runtime error |
255 ms |
262144 KB |
Execution killed with signal 9 |
14 |
Runtime error |
226 ms |
262144 KB |
Execution killed with signal 9 |
15 |
Runtime error |
233 ms |
262144 KB |
Execution killed with signal 9 |
16 |
Runtime error |
249 ms |
262144 KB |
Execution killed with signal 9 |
17 |
Runtime error |
242 ms |
262144 KB |
Execution killed with signal 9 |
18 |
Runtime error |
256 ms |
262144 KB |
Execution killed with signal 9 |
19 |
Runtime error |
238 ms |
262144 KB |
Execution killed with signal 9 |
20 |
Runtime error |
246 ms |
262144 KB |
Execution killed with signal 9 |
21 |
Runtime error |
256 ms |
262144 KB |
Execution killed with signal 9 |
22 |
Runtime error |
246 ms |
262144 KB |
Execution killed with signal 9 |
23 |
Runtime error |
261 ms |
262144 KB |
Execution killed with signal 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
147 ms |
16552 KB |
wrong parameter |
2 |
Incorrect |
2 ms |
11268 KB |
wrong parameter |
3 |
Runtime error |
236 ms |
262144 KB |
Execution killed with signal 9 |
4 |
Incorrect |
1 ms |
11268 KB |
wrong parameter |
5 |
Runtime error |
231 ms |
262144 KB |
Execution killed with signal 9 |
6 |
Runtime error |
255 ms |
262144 KB |
Execution killed with signal 9 |
7 |
Runtime error |
249 ms |
262144 KB |
Execution killed with signal 9 |
8 |
Runtime error |
239 ms |
262144 KB |
Execution killed with signal 9 |
9 |
Runtime error |
239 ms |
262144 KB |
Execution killed with signal 9 |
10 |
Runtime error |
232 ms |
262144 KB |
Execution killed with signal 9 |
11 |
Runtime error |
226 ms |
262144 KB |
Execution killed with signal 9 |
12 |
Runtime error |
232 ms |
262144 KB |
Execution killed with signal 9 |
13 |
Runtime error |
255 ms |
262144 KB |
Execution killed with signal 9 |
14 |
Runtime error |
226 ms |
262144 KB |
Execution killed with signal 9 |
15 |
Runtime error |
233 ms |
262144 KB |
Execution killed with signal 9 |
16 |
Runtime error |
249 ms |
262144 KB |
Execution killed with signal 9 |
17 |
Runtime error |
242 ms |
262144 KB |
Execution killed with signal 9 |
18 |
Runtime error |
256 ms |
262144 KB |
Execution killed with signal 9 |
19 |
Runtime error |
238 ms |
262144 KB |
Execution killed with signal 9 |
20 |
Runtime error |
246 ms |
262144 KB |
Execution killed with signal 9 |
21 |
Runtime error |
256 ms |
262144 KB |
Execution killed with signal 9 |
22 |
Runtime error |
246 ms |
262144 KB |
Execution killed with signal 9 |
23 |
Runtime error |
261 ms |
262144 KB |
Execution killed with signal 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
147 ms |
16552 KB |
wrong parameter |
2 |
Incorrect |
2 ms |
11268 KB |
wrong parameter |
3 |
Runtime error |
236 ms |
262144 KB |
Execution killed with signal 9 |
4 |
Incorrect |
1 ms |
11268 KB |
wrong parameter |
5 |
Runtime error |
231 ms |
262144 KB |
Execution killed with signal 9 |
6 |
Runtime error |
255 ms |
262144 KB |
Execution killed with signal 9 |
7 |
Runtime error |
249 ms |
262144 KB |
Execution killed with signal 9 |
8 |
Runtime error |
239 ms |
262144 KB |
Execution killed with signal 9 |
9 |
Runtime error |
239 ms |
262144 KB |
Execution killed with signal 9 |
10 |
Runtime error |
232 ms |
262144 KB |
Execution killed with signal 9 |
11 |
Runtime error |
226 ms |
262144 KB |
Execution killed with signal 9 |
12 |
Runtime error |
232 ms |
262144 KB |
Execution killed with signal 9 |
13 |
Runtime error |
255 ms |
262144 KB |
Execution killed with signal 9 |
14 |
Runtime error |
226 ms |
262144 KB |
Execution killed with signal 9 |
15 |
Runtime error |
233 ms |
262144 KB |
Execution killed with signal 9 |
16 |
Runtime error |
249 ms |
262144 KB |
Execution killed with signal 9 |
17 |
Runtime error |
242 ms |
262144 KB |
Execution killed with signal 9 |
18 |
Runtime error |
256 ms |
262144 KB |
Execution killed with signal 9 |
19 |
Runtime error |
238 ms |
262144 KB |
Execution killed with signal 9 |
20 |
Runtime error |
246 ms |
262144 KB |
Execution killed with signal 9 |
21 |
Runtime error |
256 ms |
262144 KB |
Execution killed with signal 9 |
22 |
Runtime error |
246 ms |
262144 KB |
Execution killed with signal 9 |
23 |
Runtime error |
261 ms |
262144 KB |
Execution killed with signal 9 |