#include "bits/stdc++.h"
using namespace std;
#include "grader.h"
#include "encoder.h"
void encode(int n, int h, int p, int a[], int b[]) {
vector<int> v[n];
for(int i = 0; i < p; i++) {
v[a[i]].push_back(b[i]);
v[b[i]].push_back(a[i]);
}
bool vis[n];
int dd[n];
for(int i = n - 1; i >= 0; i--) {
for(int j = 0; j < n; j++) {
vis[j] = 0;
dd[j] = 1e9;
}
set<pair<int, int>> s;
s.insert({0, i});
dd[i] = 0;
while(s.size()) {
pair<int, int> p = *s.begin();
s.erase(s.begin());
int x = p.second;
int d = p.first;
if(vis[x])
continue;
vis[x] = 1;
for(int j : v[x]) {
if(d + (j < h) < dd[j]) {
dd[j] = d + (j < h);
vis[x] = 0;
s.insert({d + (j < h), j});
}
}
}
for(int j = min(h - 1, i); j >= 0; j--) {
for(int bit = 0; bit < 10; bit++)
encode_bit((dd[j] & (1 << bit)) > 0);
}
}
return;
}
#include "bits/stdc++.h"
using namespace std;
#include "grader.h"
#include "encoder.h"
void decode(int n, int h) {
for(int i = n - 1; i >= 0; i--) {
for(int j = min(h - 1, i); j >= 0; j--) {
int d = 0;
for(int bit = 0; bit < 10; bit++) {
if(decode_bit())
d += (1 << bit);
}
hops(j, i, d);
if(i < h && i != j)
hops(i, j, d);
}
}
return;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
859 ms |
12412 KB |
Output isn't correct |
2 |
Correct |
3 ms |
4604 KB |
Output is correct - 120 call(s) of encode_bit() |
3 |
Incorrect |
231 ms |
7320 KB |
Output isn't correct |
4 |
Correct |
2 ms |
4604 KB |
Output is correct - 150 call(s) of encode_bit() |
5 |
Incorrect |
211 ms |
7596 KB |
Output isn't correct |
6 |
Incorrect |
282 ms |
7768 KB |
Output isn't correct |
7 |
Incorrect |
311 ms |
8040 KB |
Output isn't correct |
8 |
Incorrect |
215 ms |
7344 KB |
Output isn't correct |
9 |
Incorrect |
141 ms |
7576 KB |
Output isn't correct |
10 |
Incorrect |
158 ms |
7528 KB |
Output isn't correct |
11 |
Incorrect |
199 ms |
7700 KB |
Output isn't correct |
12 |
Incorrect |
108 ms |
7560 KB |
Output isn't correct |
13 |
Incorrect |
291 ms |
8228 KB |
Output isn't correct |
14 |
Incorrect |
200 ms |
7500 KB |
Output isn't correct |
15 |
Incorrect |
161 ms |
7540 KB |
Output isn't correct |
16 |
Incorrect |
261 ms |
8064 KB |
Output isn't correct |
17 |
Incorrect |
268 ms |
8024 KB |
Output isn't correct |
18 |
Incorrect |
290 ms |
8404 KB |
Output isn't correct |
19 |
Incorrect |
255 ms |
7972 KB |
Output isn't correct |
20 |
Incorrect |
371 ms |
8788 KB |
Output isn't correct |
21 |
Incorrect |
407 ms |
8720 KB |
Output isn't correct |
22 |
Incorrect |
320 ms |
8328 KB |
Output isn't correct |
23 |
Incorrect |
418 ms |
9024 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
859 ms |
12412 KB |
Output isn't correct |
2 |
Correct |
3 ms |
4604 KB |
Output is correct - 120 call(s) of encode_bit() |
3 |
Incorrect |
231 ms |
7320 KB |
Output isn't correct |
4 |
Correct |
2 ms |
4604 KB |
Output is correct - 150 call(s) of encode_bit() |
5 |
Incorrect |
211 ms |
7596 KB |
Output isn't correct |
6 |
Incorrect |
282 ms |
7768 KB |
Output isn't correct |
7 |
Incorrect |
311 ms |
8040 KB |
Output isn't correct |
8 |
Incorrect |
215 ms |
7344 KB |
Output isn't correct |
9 |
Incorrect |
141 ms |
7576 KB |
Output isn't correct |
10 |
Incorrect |
158 ms |
7528 KB |
Output isn't correct |
11 |
Incorrect |
199 ms |
7700 KB |
Output isn't correct |
12 |
Incorrect |
108 ms |
7560 KB |
Output isn't correct |
13 |
Incorrect |
291 ms |
8228 KB |
Output isn't correct |
14 |
Incorrect |
200 ms |
7500 KB |
Output isn't correct |
15 |
Incorrect |
161 ms |
7540 KB |
Output isn't correct |
16 |
Incorrect |
261 ms |
8064 KB |
Output isn't correct |
17 |
Incorrect |
268 ms |
8024 KB |
Output isn't correct |
18 |
Incorrect |
290 ms |
8404 KB |
Output isn't correct |
19 |
Incorrect |
255 ms |
7972 KB |
Output isn't correct |
20 |
Incorrect |
371 ms |
8788 KB |
Output isn't correct |
21 |
Incorrect |
407 ms |
8720 KB |
Output isn't correct |
22 |
Incorrect |
320 ms |
8328 KB |
Output isn't correct |
23 |
Incorrect |
418 ms |
9024 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
859 ms |
12412 KB |
Output isn't correct |
2 |
Correct |
3 ms |
4604 KB |
Output is correct - 120 call(s) of encode_bit() |
3 |
Incorrect |
231 ms |
7320 KB |
Output isn't correct |
4 |
Correct |
2 ms |
4604 KB |
Output is correct - 150 call(s) of encode_bit() |
5 |
Incorrect |
211 ms |
7596 KB |
Output isn't correct |
6 |
Incorrect |
282 ms |
7768 KB |
Output isn't correct |
7 |
Incorrect |
311 ms |
8040 KB |
Output isn't correct |
8 |
Incorrect |
215 ms |
7344 KB |
Output isn't correct |
9 |
Incorrect |
141 ms |
7576 KB |
Output isn't correct |
10 |
Incorrect |
158 ms |
7528 KB |
Output isn't correct |
11 |
Incorrect |
199 ms |
7700 KB |
Output isn't correct |
12 |
Incorrect |
108 ms |
7560 KB |
Output isn't correct |
13 |
Incorrect |
291 ms |
8228 KB |
Output isn't correct |
14 |
Incorrect |
200 ms |
7500 KB |
Output isn't correct |
15 |
Incorrect |
161 ms |
7540 KB |
Output isn't correct |
16 |
Incorrect |
261 ms |
8064 KB |
Output isn't correct |
17 |
Incorrect |
268 ms |
8024 KB |
Output isn't correct |
18 |
Incorrect |
290 ms |
8404 KB |
Output isn't correct |
19 |
Incorrect |
255 ms |
7972 KB |
Output isn't correct |
20 |
Incorrect |
371 ms |
8788 KB |
Output isn't correct |
21 |
Incorrect |
407 ms |
8720 KB |
Output isn't correct |
22 |
Incorrect |
320 ms |
8328 KB |
Output isn't correct |
23 |
Incorrect |
418 ms |
9024 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
859 ms |
12412 KB |
Output isn't correct |
2 |
Correct |
3 ms |
4604 KB |
Output is correct - 120 call(s) of encode_bit() |
3 |
Incorrect |
231 ms |
7320 KB |
Output isn't correct |
4 |
Correct |
2 ms |
4604 KB |
Output is correct - 150 call(s) of encode_bit() |
5 |
Incorrect |
211 ms |
7596 KB |
Output isn't correct |
6 |
Incorrect |
282 ms |
7768 KB |
Output isn't correct |
7 |
Incorrect |
311 ms |
8040 KB |
Output isn't correct |
8 |
Incorrect |
215 ms |
7344 KB |
Output isn't correct |
9 |
Incorrect |
141 ms |
7576 KB |
Output isn't correct |
10 |
Incorrect |
158 ms |
7528 KB |
Output isn't correct |
11 |
Incorrect |
199 ms |
7700 KB |
Output isn't correct |
12 |
Incorrect |
108 ms |
7560 KB |
Output isn't correct |
13 |
Incorrect |
291 ms |
8228 KB |
Output isn't correct |
14 |
Incorrect |
200 ms |
7500 KB |
Output isn't correct |
15 |
Incorrect |
161 ms |
7540 KB |
Output isn't correct |
16 |
Incorrect |
261 ms |
8064 KB |
Output isn't correct |
17 |
Incorrect |
268 ms |
8024 KB |
Output isn't correct |
18 |
Incorrect |
290 ms |
8404 KB |
Output isn't correct |
19 |
Incorrect |
255 ms |
7972 KB |
Output isn't correct |
20 |
Incorrect |
371 ms |
8788 KB |
Output isn't correct |
21 |
Incorrect |
407 ms |
8720 KB |
Output isn't correct |
22 |
Incorrect |
320 ms |
8328 KB |
Output isn't correct |
23 |
Incorrect |
418 ms |
9024 KB |
Output isn't correct |