# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
747204 | 2023-05-23T22:57:30 Z | finn__ | Saveit (IOI10_saveit) | C++17 | 284 ms | 10408 KB |
#include "grader.h" #include "encoder.h" #include <bits/stdc++.h> using namespace std; void encode_package(int p[3]) { int z = 0; for (size_t i = 0; i < 3; ++i) z = z * 3 + p[i] + 1; for (size_t i = 4; i < 5; --i) encode_bit((z >> i) & 1); } void encode(int n, int h, int m, int *a, int *b) { if (!h) return; vector<vector<int>> g(n), d(h, vector<int>(n, -1)); vector<int> p(n), bfs_order; for (size_t i = 0; i < m; ++i) g[a[i]].push_back(b[i]), g[b[i]].push_back(a[i]); for (size_t i = 0; i < n; ++i) sort(g[i].begin(), g[i].end()); for (size_t i = 0; i < h; ++i) { queue<int> q; q.push(i); d[i][i] = 0; while (!q.empty()) { int u = q.front(); q.pop(); for (int const &v : g[u]) if (d[i][v] == -1) { d[i][v] = d[i][u] + 1; q.push(v); if (!i) p[v] = u, bfs_order.push_back(v); } } } assert(bfs_order.size() == n - 1); for (size_t i = 1; i < n; ++i) /* encode bfs tree from 0 */ for (size_t j = 9; j < 10; --j) encode_bit((p[i] >> j) & 1); int c[3]; size_t l = 0; for (int const &i : bfs_order) /* encode distance changes */ { for (size_t k = 1; k < h; ++k) { c[l++] = d[k][i] - d[k][p[i]]; if (l == 3) encode_package(c), l = 0; } } if (l) encode_package(c); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 284 ms | 10408 KB | function hops(h,c,d) must be called exactly N×H times |
2 | Incorrect | 2 ms | 4488 KB | function hops(h,c,d) must be called exactly N×H times |
3 | Incorrect | 19 ms | 5608 KB | function hops(h,c,d) must be called exactly N×H times |
4 | Incorrect | 2 ms | 4536 KB | function hops(h,c,d) must be called exactly N×H times |
5 | Incorrect | 19 ms | 5624 KB | function hops(h,c,d) must be called exactly N×H times |
6 | Incorrect | 20 ms | 5756 KB | function hops(h,c,d) must be called exactly N×H times |
7 | Incorrect | 33 ms | 6048 KB | function hops(h,c,d) must be called exactly N×H times |
8 | Incorrect | 16 ms | 5500 KB | function hops(h,c,d) must be called exactly N×H times |
9 | Incorrect | 19 ms | 5672 KB | function hops(h,c,d) must be called exactly N×H times |
10 | Incorrect | 17 ms | 5652 KB | function hops(h,c,d) must be called exactly N×H times |
11 | Incorrect | 21 ms | 5836 KB | function hops(h,c,d) must be called exactly N×H times |
12 | Incorrect | 16 ms | 5636 KB | function hops(h,c,d) must be called exactly N×H times |
13 | Incorrect | 45 ms | 6180 KB | function hops(h,c,d) must be called exactly N×H times |
14 | Incorrect | 18 ms | 5676 KB | function hops(h,c,d) must be called exactly N×H times |
15 | Incorrect | 22 ms | 5760 KB | function hops(h,c,d) must be called exactly N×H times |
16 | Incorrect | 47 ms | 6188 KB | function hops(h,c,d) must be called exactly N×H times |
17 | Incorrect | 40 ms | 6044 KB | function hops(h,c,d) must be called exactly N×H times |
18 | Incorrect | 43 ms | 6432 KB | function hops(h,c,d) must be called exactly N×H times |
19 | Incorrect | 27 ms | 5796 KB | function hops(h,c,d) must be called exactly N×H times |
20 | Incorrect | 66 ms | 6628 KB | function hops(h,c,d) must be called exactly N×H times |
21 | Incorrect | 65 ms | 6724 KB | function hops(h,c,d) must be called exactly N×H times |
22 | Incorrect | 48 ms | 6276 KB | function hops(h,c,d) must be called exactly N×H times |
23 | Incorrect | 81 ms | 7100 KB | function hops(h,c,d) must be called exactly N×H times |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 284 ms | 10408 KB | function hops(h,c,d) must be called exactly N×H times |
2 | Incorrect | 2 ms | 4488 KB | function hops(h,c,d) must be called exactly N×H times |
3 | Incorrect | 19 ms | 5608 KB | function hops(h,c,d) must be called exactly N×H times |
4 | Incorrect | 2 ms | 4536 KB | function hops(h,c,d) must be called exactly N×H times |
5 | Incorrect | 19 ms | 5624 KB | function hops(h,c,d) must be called exactly N×H times |
6 | Incorrect | 20 ms | 5756 KB | function hops(h,c,d) must be called exactly N×H times |
7 | Incorrect | 33 ms | 6048 KB | function hops(h,c,d) must be called exactly N×H times |
8 | Incorrect | 16 ms | 5500 KB | function hops(h,c,d) must be called exactly N×H times |
9 | Incorrect | 19 ms | 5672 KB | function hops(h,c,d) must be called exactly N×H times |
10 | Incorrect | 17 ms | 5652 KB | function hops(h,c,d) must be called exactly N×H times |
11 | Incorrect | 21 ms | 5836 KB | function hops(h,c,d) must be called exactly N×H times |
12 | Incorrect | 16 ms | 5636 KB | function hops(h,c,d) must be called exactly N×H times |
13 | Incorrect | 45 ms | 6180 KB | function hops(h,c,d) must be called exactly N×H times |
14 | Incorrect | 18 ms | 5676 KB | function hops(h,c,d) must be called exactly N×H times |
15 | Incorrect | 22 ms | 5760 KB | function hops(h,c,d) must be called exactly N×H times |
16 | Incorrect | 47 ms | 6188 KB | function hops(h,c,d) must be called exactly N×H times |
17 | Incorrect | 40 ms | 6044 KB | function hops(h,c,d) must be called exactly N×H times |
18 | Incorrect | 43 ms | 6432 KB | function hops(h,c,d) must be called exactly N×H times |
19 | Incorrect | 27 ms | 5796 KB | function hops(h,c,d) must be called exactly N×H times |
20 | Incorrect | 66 ms | 6628 KB | function hops(h,c,d) must be called exactly N×H times |
21 | Incorrect | 65 ms | 6724 KB | function hops(h,c,d) must be called exactly N×H times |
22 | Incorrect | 48 ms | 6276 KB | function hops(h,c,d) must be called exactly N×H times |
23 | Incorrect | 81 ms | 7100 KB | function hops(h,c,d) must be called exactly N×H times |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 284 ms | 10408 KB | function hops(h,c,d) must be called exactly N×H times |
2 | Incorrect | 2 ms | 4488 KB | function hops(h,c,d) must be called exactly N×H times |
3 | Incorrect | 19 ms | 5608 KB | function hops(h,c,d) must be called exactly N×H times |
4 | Incorrect | 2 ms | 4536 KB | function hops(h,c,d) must be called exactly N×H times |
5 | Incorrect | 19 ms | 5624 KB | function hops(h,c,d) must be called exactly N×H times |
6 | Incorrect | 20 ms | 5756 KB | function hops(h,c,d) must be called exactly N×H times |
7 | Incorrect | 33 ms | 6048 KB | function hops(h,c,d) must be called exactly N×H times |
8 | Incorrect | 16 ms | 5500 KB | function hops(h,c,d) must be called exactly N×H times |
9 | Incorrect | 19 ms | 5672 KB | function hops(h,c,d) must be called exactly N×H times |
10 | Incorrect | 17 ms | 5652 KB | function hops(h,c,d) must be called exactly N×H times |
11 | Incorrect | 21 ms | 5836 KB | function hops(h,c,d) must be called exactly N×H times |
12 | Incorrect | 16 ms | 5636 KB | function hops(h,c,d) must be called exactly N×H times |
13 | Incorrect | 45 ms | 6180 KB | function hops(h,c,d) must be called exactly N×H times |
14 | Incorrect | 18 ms | 5676 KB | function hops(h,c,d) must be called exactly N×H times |
15 | Incorrect | 22 ms | 5760 KB | function hops(h,c,d) must be called exactly N×H times |
16 | Incorrect | 47 ms | 6188 KB | function hops(h,c,d) must be called exactly N×H times |
17 | Incorrect | 40 ms | 6044 KB | function hops(h,c,d) must be called exactly N×H times |
18 | Incorrect | 43 ms | 6432 KB | function hops(h,c,d) must be called exactly N×H times |
19 | Incorrect | 27 ms | 5796 KB | function hops(h,c,d) must be called exactly N×H times |
20 | Incorrect | 66 ms | 6628 KB | function hops(h,c,d) must be called exactly N×H times |
21 | Incorrect | 65 ms | 6724 KB | function hops(h,c,d) must be called exactly N×H times |
22 | Incorrect | 48 ms | 6276 KB | function hops(h,c,d) must be called exactly N×H times |
23 | Incorrect | 81 ms | 7100 KB | function hops(h,c,d) must be called exactly N×H times |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 284 ms | 10408 KB | function hops(h,c,d) must be called exactly N×H times |
2 | Incorrect | 2 ms | 4488 KB | function hops(h,c,d) must be called exactly N×H times |
3 | Incorrect | 19 ms | 5608 KB | function hops(h,c,d) must be called exactly N×H times |
4 | Incorrect | 2 ms | 4536 KB | function hops(h,c,d) must be called exactly N×H times |
5 | Incorrect | 19 ms | 5624 KB | function hops(h,c,d) must be called exactly N×H times |
6 | Incorrect | 20 ms | 5756 KB | function hops(h,c,d) must be called exactly N×H times |
7 | Incorrect | 33 ms | 6048 KB | function hops(h,c,d) must be called exactly N×H times |
8 | Incorrect | 16 ms | 5500 KB | function hops(h,c,d) must be called exactly N×H times |
9 | Incorrect | 19 ms | 5672 KB | function hops(h,c,d) must be called exactly N×H times |
10 | Incorrect | 17 ms | 5652 KB | function hops(h,c,d) must be called exactly N×H times |
11 | Incorrect | 21 ms | 5836 KB | function hops(h,c,d) must be called exactly N×H times |
12 | Incorrect | 16 ms | 5636 KB | function hops(h,c,d) must be called exactly N×H times |
13 | Incorrect | 45 ms | 6180 KB | function hops(h,c,d) must be called exactly N×H times |
14 | Incorrect | 18 ms | 5676 KB | function hops(h,c,d) must be called exactly N×H times |
15 | Incorrect | 22 ms | 5760 KB | function hops(h,c,d) must be called exactly N×H times |
16 | Incorrect | 47 ms | 6188 KB | function hops(h,c,d) must be called exactly N×H times |
17 | Incorrect | 40 ms | 6044 KB | function hops(h,c,d) must be called exactly N×H times |
18 | Incorrect | 43 ms | 6432 KB | function hops(h,c,d) must be called exactly N×H times |
19 | Incorrect | 27 ms | 5796 KB | function hops(h,c,d) must be called exactly N×H times |
20 | Incorrect | 66 ms | 6628 KB | function hops(h,c,d) must be called exactly N×H times |
21 | Incorrect | 65 ms | 6724 KB | function hops(h,c,d) must be called exactly N×H times |
22 | Incorrect | 48 ms | 6276 KB | function hops(h,c,d) must be called exactly N×H times |
23 | Incorrect | 81 ms | 7100 KB | function hops(h,c,d) must be called exactly N×H times |