#include "grader.h"
#include "encoder.h"
#include<bits/stdc++.h>
using namespace std;
const int M = 1e4+5;
vector<vector<int>> node(M, vector<int>({}));
vector<int> vis(M, 0), dist(M, 0);
void bfs(int s) {
queue<int> q;
q.push(s);
vis[s] = true;
while (!q.empty()) {
int f = q.front(); q.pop();
for (int i:node[f]) {
if (!vis[i]) {
vis[i] = true;
dist[i] = dist[f]+1;
q.push(i);
}
}
}
}
void encode(int n, int h, int p, int *a, int *b){
for (int i = 0; i < p; i++) {
node[a[i]].push_back(b[i]);
node[b[i]].push_back(a[i]);
}
map<pair<int, int>, int> ans;
for (int i = 0; i < h; i++) {
for (int j = 0; j < n; j++) dist[j] = vis[j] = 0;
bfs(i);
for (int j = 0; j < n; j++) ans[{i, j}] = dist[j];
}
for (int i = 0; i < h; i++) {
for (int j = i+1; j < n; j++) {
for (int k = 0; k < 10; k++) {
encode_bit((ans[{i, j}]&(1<<k))!=0);
}
}
}
return;
}
#include "grader.h"
#include "decoder.h"
#include<bits/stdc++.h>
using namespace std;
void decode(int n, int h) {
vector<vector<int>> pp(n, vector<int>(n, 0));
for (int i = 0; i < h; i++) {
for (int j = i+1; j < n; j++) {
for (int k = 0; k < 10; k++) {
pp[i][j] += decode_bit()*(1<<k);
pp[j][i] = pp[i][j];
}
}
}
for (int i = 0; i < h; i++) {
for (int j = 0; j < n; j++) {
hops(i, j, pp[i][j]);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
305 ms |
18536 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
2 |
Correct |
3 ms |
4856 KB |
Output is correct - 90 call(s) of encode_bit() |
3 |
Correct |
94 ms |
12796 KB |
Output is partially correct - 317340 call(s) of encode_bit() |
4 |
Correct |
3 ms |
4872 KB |
Output is correct - 100 call(s) of encode_bit() |
5 |
Correct |
90 ms |
12880 KB |
Output is partially correct - 317340 call(s) of encode_bit() |
6 |
Correct |
119 ms |
14164 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
7 |
Correct |
110 ms |
14564 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
8 |
Correct |
99 ms |
13608 KB |
Output is partially correct - 339300 call(s) of encode_bit() |
9 |
Correct |
107 ms |
13876 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
10 |
Correct |
98 ms |
13844 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
11 |
Correct |
122 ms |
14052 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
12 |
Correct |
106 ms |
13976 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
13 |
Correct |
134 ms |
14600 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
14 |
Correct |
111 ms |
14068 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
15 |
Correct |
101 ms |
13988 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
16 |
Correct |
125 ms |
14456 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
17 |
Correct |
138 ms |
14432 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
18 |
Correct |
120 ms |
14676 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
19 |
Correct |
111 ms |
14376 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
20 |
Correct |
139 ms |
14920 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
21 |
Correct |
141 ms |
15316 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
22 |
Correct |
132 ms |
14664 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
23 |
Correct |
142 ms |
15264 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
305 ms |
18536 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
2 |
Correct |
3 ms |
4856 KB |
Output is correct - 90 call(s) of encode_bit() |
3 |
Correct |
94 ms |
12796 KB |
Output is partially correct - 317340 call(s) of encode_bit() |
4 |
Correct |
3 ms |
4872 KB |
Output is correct - 100 call(s) of encode_bit() |
5 |
Correct |
90 ms |
12880 KB |
Output is partially correct - 317340 call(s) of encode_bit() |
6 |
Correct |
119 ms |
14164 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
7 |
Correct |
110 ms |
14564 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
8 |
Correct |
99 ms |
13608 KB |
Output is partially correct - 339300 call(s) of encode_bit() |
9 |
Correct |
107 ms |
13876 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
10 |
Correct |
98 ms |
13844 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
11 |
Correct |
122 ms |
14052 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
12 |
Correct |
106 ms |
13976 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
13 |
Correct |
134 ms |
14600 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
14 |
Correct |
111 ms |
14068 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
15 |
Correct |
101 ms |
13988 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
16 |
Correct |
125 ms |
14456 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
17 |
Correct |
138 ms |
14432 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
18 |
Correct |
120 ms |
14676 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
19 |
Correct |
111 ms |
14376 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
20 |
Correct |
139 ms |
14920 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
21 |
Correct |
141 ms |
15316 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
22 |
Correct |
132 ms |
14664 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
23 |
Correct |
142 ms |
15264 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
305 ms |
18536 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
2 |
Correct |
3 ms |
4856 KB |
Output is correct - 90 call(s) of encode_bit() |
3 |
Correct |
94 ms |
12796 KB |
Output is partially correct - 317340 call(s) of encode_bit() |
4 |
Correct |
3 ms |
4872 KB |
Output is correct - 100 call(s) of encode_bit() |
5 |
Correct |
90 ms |
12880 KB |
Output is partially correct - 317340 call(s) of encode_bit() |
6 |
Correct |
119 ms |
14164 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
7 |
Correct |
110 ms |
14564 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
8 |
Correct |
99 ms |
13608 KB |
Output is partially correct - 339300 call(s) of encode_bit() |
9 |
Correct |
107 ms |
13876 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
10 |
Correct |
98 ms |
13844 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
11 |
Correct |
122 ms |
14052 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
12 |
Correct |
106 ms |
13976 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
13 |
Correct |
134 ms |
14600 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
14 |
Correct |
111 ms |
14068 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
15 |
Correct |
101 ms |
13988 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
16 |
Correct |
125 ms |
14456 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
17 |
Correct |
138 ms |
14432 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
18 |
Correct |
120 ms |
14676 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
19 |
Correct |
111 ms |
14376 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
20 |
Correct |
139 ms |
14920 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
21 |
Correct |
141 ms |
15316 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
22 |
Correct |
132 ms |
14664 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
23 |
Correct |
142 ms |
15264 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
305 ms |
18536 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
2 |
Correct |
3 ms |
4856 KB |
Output is correct - 90 call(s) of encode_bit() |
3 |
Correct |
94 ms |
12796 KB |
Output is partially correct - 317340 call(s) of encode_bit() |
4 |
Correct |
3 ms |
4872 KB |
Output is correct - 100 call(s) of encode_bit() |
5 |
Correct |
90 ms |
12880 KB |
Output is partially correct - 317340 call(s) of encode_bit() |
6 |
Correct |
119 ms |
14164 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
7 |
Correct |
110 ms |
14564 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
8 |
Correct |
99 ms |
13608 KB |
Output is partially correct - 339300 call(s) of encode_bit() |
9 |
Correct |
107 ms |
13876 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
10 |
Correct |
98 ms |
13844 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
11 |
Correct |
122 ms |
14052 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
12 |
Correct |
106 ms |
13976 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
13 |
Correct |
134 ms |
14600 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
14 |
Correct |
111 ms |
14068 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
15 |
Correct |
101 ms |
13988 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
16 |
Correct |
125 ms |
14456 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
17 |
Correct |
138 ms |
14432 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
18 |
Correct |
120 ms |
14676 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
19 |
Correct |
111 ms |
14376 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
20 |
Correct |
139 ms |
14920 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
21 |
Correct |
141 ms |
15316 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
22 |
Correct |
132 ms |
14664 KB |
Output is partially correct - 353340 call(s) of encode_bit() |
23 |
Correct |
142 ms |
15264 KB |
Output is partially correct - 353340 call(s) of encode_bit() |