#include "grader.h"
#include "encoder.h"
#include <bits/stdc++.h>
using namespace std;
void encode(int n, int nh, int ne, int *v1, int *v2){
int g[n][n];
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
g[i][j] = 0;
}
}
for (int i = 0; i < ne; ++i) {
g[v1[i]][v2[i]] = g[v2[i]][v1[i]] = 1;
}
int inf = 1e9;
int d[nh][n];
for (int i = 0; i < nh; ++i) {
for (int j = 0; j < n; ++j) {
d[i][j] = 0;
}
}
for (int i = 0; i < nh; ++i) {
vector<int> c(1, i);
d[i][i] = 0;
for (int cd = 0; cd < n; ++cd) {
vector<int> nc;
for (auto x: c) {
for (int y = 0; y < n; ++y) {
if (d[i][y] == inf && g[x][y] == 2) {
d[i][y] = cd + 1;
nc.push_back(y);
}
}
}
for (auto x: c) {
for (int y = 0; y < n; ++y) {
if (d[i][y] == inf && g[x][y] == 1) {
d[i][y] = cd + 1;
g[x][y] = g[y][x] = 2;
nc.push_back(y);
}
}
}
c = nc;
}
}
for (int i = 0; i < n; ++i) {
int c = 0;
for (int j = i + 1; j < n; ++j) {
c += g[i][j] == 2;
}
if (n < c * 10) {
encode_bit(0);
for (int j = i + 1; j < n; ++j) {
encode_bit(g[i][j] == 2);
}
} else {
encode_bit(1);
int mx = 0;
for (int j = i + 1; j < n; ++j) if (g[i][j] == 2) mx = j;
for (int j = i + 1; j < n; ++j) {
if (g[i][j] != 2) continue;
for (int b = 0; b < 10; ++b) {
encode_bit(((1 << b) & j) >> b);
}
if (j < mx) encode_bit(1);
}
encode_bit(0);
}
}
return;
}
// int main() {
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// return 0;
// }
#include "grader.h"
#include "decoder.h"
#include <bits/stdc++.h>
using namespace std;
void decode(int n, int nh) {
int g[n][n];
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
g[i][j] = 0;
}
}
for (int i = 0; i < n; ++i) {
int t = decode_bit();
if (t == 0) {
for (int j = i + 1; j < n; ++j) {
if (decode_bit()) {
g[i][j] = g[j][i] = 1;
}
}
} else {
while (decode_bit()) {
int x = 0;
for (int b = 0; b < 10; ++b) {
x += (decode_bit() << b);
}
g[i][x] = g[x][i] = 1;
}
}
}
for (int k = 0; k < nh; ++k) {
vector<int> d(n, 1e9);
d[k] = 0;
queue<int> q;
q.push(k);
while (!q.empty()) {
auto x = q.front();
q.pop();
for (int y = 0; y < n; ++y) {
if (y != x && d[y] > n) {
d[y] = d[x] + 1;
q.push(y);
}
}
}
for (int i = 0; i < n; ++i) {
hops(k, i, d[i]);
}
}
}
// int main() {
// ios_base::sync_with_stdio(false);
// cin.tie(0);
// return 0;
// }
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
242 ms |
21484 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
11264 KB |
Output isn't correct |
3 |
Incorrect |
83 ms |
17556 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
11680 KB |
Output isn't correct |
5 |
Incorrect |
84 ms |
17832 KB |
Output isn't correct |
6 |
Incorrect |
103 ms |
19332 KB |
Output isn't correct |
7 |
Incorrect |
117 ms |
19668 KB |
Output isn't correct |
8 |
Incorrect |
94 ms |
18692 KB |
Output isn't correct |
9 |
Incorrect |
102 ms |
19072 KB |
Output isn't correct |
10 |
Incorrect |
101 ms |
19264 KB |
Output isn't correct |
11 |
Incorrect |
104 ms |
19092 KB |
Output isn't correct |
12 |
Incorrect |
102 ms |
19068 KB |
Output isn't correct |
13 |
Incorrect |
129 ms |
19244 KB |
Output isn't correct |
14 |
Incorrect |
102 ms |
19208 KB |
Output isn't correct |
15 |
Incorrect |
101 ms |
19220 KB |
Output isn't correct |
16 |
Incorrect |
115 ms |
19596 KB |
Output isn't correct |
17 |
Incorrect |
117 ms |
19136 KB |
Output isn't correct |
18 |
Incorrect |
132 ms |
19196 KB |
Output isn't correct |
19 |
Incorrect |
112 ms |
19388 KB |
Output isn't correct |
20 |
Incorrect |
130 ms |
21600 KB |
Output isn't correct |
21 |
Incorrect |
143 ms |
22356 KB |
Output isn't correct |
22 |
Incorrect |
125 ms |
19772 KB |
Output isn't correct |
23 |
Incorrect |
144 ms |
21348 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
242 ms |
21484 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
11264 KB |
Output isn't correct |
3 |
Incorrect |
83 ms |
17556 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
11680 KB |
Output isn't correct |
5 |
Incorrect |
84 ms |
17832 KB |
Output isn't correct |
6 |
Incorrect |
103 ms |
19332 KB |
Output isn't correct |
7 |
Incorrect |
117 ms |
19668 KB |
Output isn't correct |
8 |
Incorrect |
94 ms |
18692 KB |
Output isn't correct |
9 |
Incorrect |
102 ms |
19072 KB |
Output isn't correct |
10 |
Incorrect |
101 ms |
19264 KB |
Output isn't correct |
11 |
Incorrect |
104 ms |
19092 KB |
Output isn't correct |
12 |
Incorrect |
102 ms |
19068 KB |
Output isn't correct |
13 |
Incorrect |
129 ms |
19244 KB |
Output isn't correct |
14 |
Incorrect |
102 ms |
19208 KB |
Output isn't correct |
15 |
Incorrect |
101 ms |
19220 KB |
Output isn't correct |
16 |
Incorrect |
115 ms |
19596 KB |
Output isn't correct |
17 |
Incorrect |
117 ms |
19136 KB |
Output isn't correct |
18 |
Incorrect |
132 ms |
19196 KB |
Output isn't correct |
19 |
Incorrect |
112 ms |
19388 KB |
Output isn't correct |
20 |
Incorrect |
130 ms |
21600 KB |
Output isn't correct |
21 |
Incorrect |
143 ms |
22356 KB |
Output isn't correct |
22 |
Incorrect |
125 ms |
19772 KB |
Output isn't correct |
23 |
Incorrect |
144 ms |
21348 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
242 ms |
21484 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
11264 KB |
Output isn't correct |
3 |
Incorrect |
83 ms |
17556 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
11680 KB |
Output isn't correct |
5 |
Incorrect |
84 ms |
17832 KB |
Output isn't correct |
6 |
Incorrect |
103 ms |
19332 KB |
Output isn't correct |
7 |
Incorrect |
117 ms |
19668 KB |
Output isn't correct |
8 |
Incorrect |
94 ms |
18692 KB |
Output isn't correct |
9 |
Incorrect |
102 ms |
19072 KB |
Output isn't correct |
10 |
Incorrect |
101 ms |
19264 KB |
Output isn't correct |
11 |
Incorrect |
104 ms |
19092 KB |
Output isn't correct |
12 |
Incorrect |
102 ms |
19068 KB |
Output isn't correct |
13 |
Incorrect |
129 ms |
19244 KB |
Output isn't correct |
14 |
Incorrect |
102 ms |
19208 KB |
Output isn't correct |
15 |
Incorrect |
101 ms |
19220 KB |
Output isn't correct |
16 |
Incorrect |
115 ms |
19596 KB |
Output isn't correct |
17 |
Incorrect |
117 ms |
19136 KB |
Output isn't correct |
18 |
Incorrect |
132 ms |
19196 KB |
Output isn't correct |
19 |
Incorrect |
112 ms |
19388 KB |
Output isn't correct |
20 |
Incorrect |
130 ms |
21600 KB |
Output isn't correct |
21 |
Incorrect |
143 ms |
22356 KB |
Output isn't correct |
22 |
Incorrect |
125 ms |
19772 KB |
Output isn't correct |
23 |
Incorrect |
144 ms |
21348 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
242 ms |
21484 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
11264 KB |
Output isn't correct |
3 |
Incorrect |
83 ms |
17556 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
11680 KB |
Output isn't correct |
5 |
Incorrect |
84 ms |
17832 KB |
Output isn't correct |
6 |
Incorrect |
103 ms |
19332 KB |
Output isn't correct |
7 |
Incorrect |
117 ms |
19668 KB |
Output isn't correct |
8 |
Incorrect |
94 ms |
18692 KB |
Output isn't correct |
9 |
Incorrect |
102 ms |
19072 KB |
Output isn't correct |
10 |
Incorrect |
101 ms |
19264 KB |
Output isn't correct |
11 |
Incorrect |
104 ms |
19092 KB |
Output isn't correct |
12 |
Incorrect |
102 ms |
19068 KB |
Output isn't correct |
13 |
Incorrect |
129 ms |
19244 KB |
Output isn't correct |
14 |
Incorrect |
102 ms |
19208 KB |
Output isn't correct |
15 |
Incorrect |
101 ms |
19220 KB |
Output isn't correct |
16 |
Incorrect |
115 ms |
19596 KB |
Output isn't correct |
17 |
Incorrect |
117 ms |
19136 KB |
Output isn't correct |
18 |
Incorrect |
132 ms |
19196 KB |
Output isn't correct |
19 |
Incorrect |
112 ms |
19388 KB |
Output isn't correct |
20 |
Incorrect |
130 ms |
21600 KB |
Output isn't correct |
21 |
Incorrect |
143 ms |
22356 KB |
Output isn't correct |
22 |
Incorrect |
125 ms |
19772 KB |
Output isn't correct |
23 |
Incorrect |
144 ms |
21348 KB |
Output isn't correct |