#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[v] = (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]);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
163 ms |
17080 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
11268 KB |
Output isn't correct |
3 |
Incorrect |
72 ms |
15412 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
11268 KB |
Output isn't correct |
5 |
Incorrect |
32 ms |
13100 KB |
Output isn't correct |
6 |
Incorrect |
40 ms |
13356 KB |
Output isn't correct |
7 |
Incorrect |
42 ms |
12736 KB |
Output isn't correct |
8 |
Incorrect |
430 ms |
36680 KB |
Output isn't correct |
9 |
Runtime error |
271 ms |
262144 KB |
Execution killed with signal 9 |
10 |
Incorrect |
47 ms |
12880 KB |
Output isn't correct |
11 |
Incorrect |
92 ms |
18808 KB |
Output isn't correct |
12 |
Incorrect |
3056 ms |
144044 KB |
Output isn't correct |
13 |
Incorrect |
185 ms |
25328 KB |
Output isn't correct |
14 |
Incorrect |
1045 ms |
78328 KB |
Output isn't correct |
15 |
Incorrect |
1250 ms |
78580 KB |
Output isn't correct |
16 |
Incorrect |
405 ms |
40188 KB |
Output isn't correct |
17 |
Incorrect |
364 ms |
40480 KB |
Output isn't correct |
18 |
Incorrect |
217 ms |
18832 KB |
Output isn't correct |
19 |
Incorrect |
182 ms |
19152 KB |
Output isn't correct |
20 |
Incorrect |
942 ms |
64424 KB |
Output isn't correct |
21 |
Incorrect |
193 ms |
20944 KB |
Output isn't correct |
22 |
Incorrect |
170 ms |
15936 KB |
Output isn't correct |
23 |
Incorrect |
172 ms |
18932 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
163 ms |
17080 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
11268 KB |
Output isn't correct |
3 |
Incorrect |
72 ms |
15412 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
11268 KB |
Output isn't correct |
5 |
Incorrect |
32 ms |
13100 KB |
Output isn't correct |
6 |
Incorrect |
40 ms |
13356 KB |
Output isn't correct |
7 |
Incorrect |
42 ms |
12736 KB |
Output isn't correct |
8 |
Incorrect |
430 ms |
36680 KB |
Output isn't correct |
9 |
Runtime error |
271 ms |
262144 KB |
Execution killed with signal 9 |
10 |
Incorrect |
47 ms |
12880 KB |
Output isn't correct |
11 |
Incorrect |
92 ms |
18808 KB |
Output isn't correct |
12 |
Incorrect |
3056 ms |
144044 KB |
Output isn't correct |
13 |
Incorrect |
185 ms |
25328 KB |
Output isn't correct |
14 |
Incorrect |
1045 ms |
78328 KB |
Output isn't correct |
15 |
Incorrect |
1250 ms |
78580 KB |
Output isn't correct |
16 |
Incorrect |
405 ms |
40188 KB |
Output isn't correct |
17 |
Incorrect |
364 ms |
40480 KB |
Output isn't correct |
18 |
Incorrect |
217 ms |
18832 KB |
Output isn't correct |
19 |
Incorrect |
182 ms |
19152 KB |
Output isn't correct |
20 |
Incorrect |
942 ms |
64424 KB |
Output isn't correct |
21 |
Incorrect |
193 ms |
20944 KB |
Output isn't correct |
22 |
Incorrect |
170 ms |
15936 KB |
Output isn't correct |
23 |
Incorrect |
172 ms |
18932 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
163 ms |
17080 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
11268 KB |
Output isn't correct |
3 |
Incorrect |
72 ms |
15412 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
11268 KB |
Output isn't correct |
5 |
Incorrect |
32 ms |
13100 KB |
Output isn't correct |
6 |
Incorrect |
40 ms |
13356 KB |
Output isn't correct |
7 |
Incorrect |
42 ms |
12736 KB |
Output isn't correct |
8 |
Incorrect |
430 ms |
36680 KB |
Output isn't correct |
9 |
Runtime error |
271 ms |
262144 KB |
Execution killed with signal 9 |
10 |
Incorrect |
47 ms |
12880 KB |
Output isn't correct |
11 |
Incorrect |
92 ms |
18808 KB |
Output isn't correct |
12 |
Incorrect |
3056 ms |
144044 KB |
Output isn't correct |
13 |
Incorrect |
185 ms |
25328 KB |
Output isn't correct |
14 |
Incorrect |
1045 ms |
78328 KB |
Output isn't correct |
15 |
Incorrect |
1250 ms |
78580 KB |
Output isn't correct |
16 |
Incorrect |
405 ms |
40188 KB |
Output isn't correct |
17 |
Incorrect |
364 ms |
40480 KB |
Output isn't correct |
18 |
Incorrect |
217 ms |
18832 KB |
Output isn't correct |
19 |
Incorrect |
182 ms |
19152 KB |
Output isn't correct |
20 |
Incorrect |
942 ms |
64424 KB |
Output isn't correct |
21 |
Incorrect |
193 ms |
20944 KB |
Output isn't correct |
22 |
Incorrect |
170 ms |
15936 KB |
Output isn't correct |
23 |
Incorrect |
172 ms |
18932 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
163 ms |
17080 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
11268 KB |
Output isn't correct |
3 |
Incorrect |
72 ms |
15412 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
11268 KB |
Output isn't correct |
5 |
Incorrect |
32 ms |
13100 KB |
Output isn't correct |
6 |
Incorrect |
40 ms |
13356 KB |
Output isn't correct |
7 |
Incorrect |
42 ms |
12736 KB |
Output isn't correct |
8 |
Incorrect |
430 ms |
36680 KB |
Output isn't correct |
9 |
Runtime error |
271 ms |
262144 KB |
Execution killed with signal 9 |
10 |
Incorrect |
47 ms |
12880 KB |
Output isn't correct |
11 |
Incorrect |
92 ms |
18808 KB |
Output isn't correct |
12 |
Incorrect |
3056 ms |
144044 KB |
Output isn't correct |
13 |
Incorrect |
185 ms |
25328 KB |
Output isn't correct |
14 |
Incorrect |
1045 ms |
78328 KB |
Output isn't correct |
15 |
Incorrect |
1250 ms |
78580 KB |
Output isn't correct |
16 |
Incorrect |
405 ms |
40188 KB |
Output isn't correct |
17 |
Incorrect |
364 ms |
40480 KB |
Output isn't correct |
18 |
Incorrect |
217 ms |
18832 KB |
Output isn't correct |
19 |
Incorrect |
182 ms |
19152 KB |
Output isn't correct |
20 |
Incorrect |
942 ms |
64424 KB |
Output isn't correct |
21 |
Incorrect |
193 ms |
20944 KB |
Output isn't correct |
22 |
Incorrect |
170 ms |
15936 KB |
Output isn't correct |
23 |
Incorrect |
172 ms |
18932 KB |
Output isn't correct |