# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
747201 |
2023-05-23T22:32:16 Z |
finn__ |
Saveit (IOI10_saveit) |
C++17 |
|
238 ms |
9976 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;
}
}
}
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);
}
#include "grader.h"
#include "decoder.h"
#include <bits/stdc++.h>
using namespace std;
void decode_package(int p[3])
{
int z = 0;
for (size_t i = 0; i < 5; ++i)
z = (z << 1) | decode_bit();
for (size_t i = 2; i < 3; --i)
p[i] = (z % 3) - 1, z /= 3;
}
void decode(int n, int h)
{
if (!h)
return;
vector<vector<int>> t(n), d(h, vector<int>(n));
vector<int> p(n), bfs_order;
hops(0, 0, 0);
for (size_t i = 1; i < n; ++i)
{
for (size_t j = 0; j < 10; ++j)
p[i] = (p[i] << 1) | decode_bit();
t[p[i]].push_back(i);
}
queue<int> q;
q.push(0);
while (!q.empty())
{
int u = q.front();
q.pop();
for (int const &v : t[u])
bfs_order.push_back(v), q.push(v);
}
for (int const &i : bfs_order)
hops(0, i, d[0][i] = d[0][p[i]] + 1);
size_t l = 3;
int c[3];
for (int const &i : bfs_order)
for (size_t k = 1; k < h; ++k)
{
if (l == 3)
decode_package(c), l = 0;
d[k][i] = d[k][p[i]] + c[l++];
hops(k, i, d[k][i]);
}
}
Compilation message
encoder.cpp: In function 'void encode(int, int, int, int*, int*)':
encoder.cpp:22:26: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
22 | for (size_t i = 0; i < m; ++i)
| ~~^~~
encoder.cpp:24:26: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
24 | for (size_t i = 0; i < n; ++i)
| ~~^~~
encoder.cpp:27:26: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
27 | for (size_t i = 0; i < h; ++i)
| ~~^~~
encoder.cpp:47:26: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
47 | for (size_t i = 1; i < n; ++i) /* encode bfs tree from 0 */
| ~~^~~
encoder.cpp:54:30: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
54 | for (size_t k = 1; k < h; ++k)
| ~~^~~
decoder.cpp: In function 'void decode(int, int)':
decoder.cpp:23:26: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
23 | for (size_t i = 1; i < n; ++i)
| ~~^~~
decoder.cpp:45:30: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
45 | for (size_t k = 1; k < h; ++k)
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
238 ms |
9976 KB |
too many decode_bit() calls |
2 |
Incorrect |
2 ms |
4604 KB |
too many decode_bit() calls |
3 |
Incorrect |
8 ms |
5116 KB |
too many decode_bit() calls |
4 |
Incorrect |
3 ms |
4612 KB |
too many decode_bit() calls |
5 |
Incorrect |
9 ms |
5220 KB |
too many decode_bit() calls |
6 |
Incorrect |
13 ms |
5376 KB |
too many decode_bit() calls |
7 |
Incorrect |
28 ms |
5600 KB |
too many decode_bit() calls |
8 |
Incorrect |
8 ms |
5112 KB |
too many decode_bit() calls |
9 |
Incorrect |
9 ms |
5168 KB |
too many decode_bit() calls |
10 |
Incorrect |
11 ms |
5252 KB |
too many decode_bit() calls |
11 |
Incorrect |
13 ms |
5368 KB |
too many decode_bit() calls |
12 |
Incorrect |
9 ms |
5116 KB |
too many decode_bit() calls |
13 |
Incorrect |
34 ms |
5724 KB |
too many decode_bit() calls |
14 |
Incorrect |
10 ms |
5176 KB |
too many decode_bit() calls |
15 |
Incorrect |
10 ms |
5180 KB |
too many decode_bit() calls |
16 |
Incorrect |
28 ms |
5620 KB |
too many decode_bit() calls |
17 |
Incorrect |
28 ms |
5688 KB |
too many decode_bit() calls |
18 |
Incorrect |
51 ms |
5908 KB |
too many decode_bit() calls |
19 |
Incorrect |
18 ms |
5612 KB |
too many decode_bit() calls |
20 |
Incorrect |
58 ms |
6212 KB |
too many decode_bit() calls |
21 |
Incorrect |
65 ms |
6332 KB |
too many decode_bit() calls |
22 |
Incorrect |
35 ms |
5788 KB |
too many decode_bit() calls |
23 |
Incorrect |
68 ms |
6572 KB |
too many decode_bit() calls |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
238 ms |
9976 KB |
too many decode_bit() calls |
2 |
Incorrect |
2 ms |
4604 KB |
too many decode_bit() calls |
3 |
Incorrect |
8 ms |
5116 KB |
too many decode_bit() calls |
4 |
Incorrect |
3 ms |
4612 KB |
too many decode_bit() calls |
5 |
Incorrect |
9 ms |
5220 KB |
too many decode_bit() calls |
6 |
Incorrect |
13 ms |
5376 KB |
too many decode_bit() calls |
7 |
Incorrect |
28 ms |
5600 KB |
too many decode_bit() calls |
8 |
Incorrect |
8 ms |
5112 KB |
too many decode_bit() calls |
9 |
Incorrect |
9 ms |
5168 KB |
too many decode_bit() calls |
10 |
Incorrect |
11 ms |
5252 KB |
too many decode_bit() calls |
11 |
Incorrect |
13 ms |
5368 KB |
too many decode_bit() calls |
12 |
Incorrect |
9 ms |
5116 KB |
too many decode_bit() calls |
13 |
Incorrect |
34 ms |
5724 KB |
too many decode_bit() calls |
14 |
Incorrect |
10 ms |
5176 KB |
too many decode_bit() calls |
15 |
Incorrect |
10 ms |
5180 KB |
too many decode_bit() calls |
16 |
Incorrect |
28 ms |
5620 KB |
too many decode_bit() calls |
17 |
Incorrect |
28 ms |
5688 KB |
too many decode_bit() calls |
18 |
Incorrect |
51 ms |
5908 KB |
too many decode_bit() calls |
19 |
Incorrect |
18 ms |
5612 KB |
too many decode_bit() calls |
20 |
Incorrect |
58 ms |
6212 KB |
too many decode_bit() calls |
21 |
Incorrect |
65 ms |
6332 KB |
too many decode_bit() calls |
22 |
Incorrect |
35 ms |
5788 KB |
too many decode_bit() calls |
23 |
Incorrect |
68 ms |
6572 KB |
too many decode_bit() calls |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
238 ms |
9976 KB |
too many decode_bit() calls |
2 |
Incorrect |
2 ms |
4604 KB |
too many decode_bit() calls |
3 |
Incorrect |
8 ms |
5116 KB |
too many decode_bit() calls |
4 |
Incorrect |
3 ms |
4612 KB |
too many decode_bit() calls |
5 |
Incorrect |
9 ms |
5220 KB |
too many decode_bit() calls |
6 |
Incorrect |
13 ms |
5376 KB |
too many decode_bit() calls |
7 |
Incorrect |
28 ms |
5600 KB |
too many decode_bit() calls |
8 |
Incorrect |
8 ms |
5112 KB |
too many decode_bit() calls |
9 |
Incorrect |
9 ms |
5168 KB |
too many decode_bit() calls |
10 |
Incorrect |
11 ms |
5252 KB |
too many decode_bit() calls |
11 |
Incorrect |
13 ms |
5368 KB |
too many decode_bit() calls |
12 |
Incorrect |
9 ms |
5116 KB |
too many decode_bit() calls |
13 |
Incorrect |
34 ms |
5724 KB |
too many decode_bit() calls |
14 |
Incorrect |
10 ms |
5176 KB |
too many decode_bit() calls |
15 |
Incorrect |
10 ms |
5180 KB |
too many decode_bit() calls |
16 |
Incorrect |
28 ms |
5620 KB |
too many decode_bit() calls |
17 |
Incorrect |
28 ms |
5688 KB |
too many decode_bit() calls |
18 |
Incorrect |
51 ms |
5908 KB |
too many decode_bit() calls |
19 |
Incorrect |
18 ms |
5612 KB |
too many decode_bit() calls |
20 |
Incorrect |
58 ms |
6212 KB |
too many decode_bit() calls |
21 |
Incorrect |
65 ms |
6332 KB |
too many decode_bit() calls |
22 |
Incorrect |
35 ms |
5788 KB |
too many decode_bit() calls |
23 |
Incorrect |
68 ms |
6572 KB |
too many decode_bit() calls |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
238 ms |
9976 KB |
too many decode_bit() calls |
2 |
Incorrect |
2 ms |
4604 KB |
too many decode_bit() calls |
3 |
Incorrect |
8 ms |
5116 KB |
too many decode_bit() calls |
4 |
Incorrect |
3 ms |
4612 KB |
too many decode_bit() calls |
5 |
Incorrect |
9 ms |
5220 KB |
too many decode_bit() calls |
6 |
Incorrect |
13 ms |
5376 KB |
too many decode_bit() calls |
7 |
Incorrect |
28 ms |
5600 KB |
too many decode_bit() calls |
8 |
Incorrect |
8 ms |
5112 KB |
too many decode_bit() calls |
9 |
Incorrect |
9 ms |
5168 KB |
too many decode_bit() calls |
10 |
Incorrect |
11 ms |
5252 KB |
too many decode_bit() calls |
11 |
Incorrect |
13 ms |
5368 KB |
too many decode_bit() calls |
12 |
Incorrect |
9 ms |
5116 KB |
too many decode_bit() calls |
13 |
Incorrect |
34 ms |
5724 KB |
too many decode_bit() calls |
14 |
Incorrect |
10 ms |
5176 KB |
too many decode_bit() calls |
15 |
Incorrect |
10 ms |
5180 KB |
too many decode_bit() calls |
16 |
Incorrect |
28 ms |
5620 KB |
too many decode_bit() calls |
17 |
Incorrect |
28 ms |
5688 KB |
too many decode_bit() calls |
18 |
Incorrect |
51 ms |
5908 KB |
too many decode_bit() calls |
19 |
Incorrect |
18 ms |
5612 KB |
too many decode_bit() calls |
20 |
Incorrect |
58 ms |
6212 KB |
too many decode_bit() calls |
21 |
Incorrect |
65 ms |
6332 KB |
too many decode_bit() calls |
22 |
Incorrect |
35 ms |
5788 KB |
too many decode_bit() calls |
23 |
Incorrect |
68 ms |
6572 KB |
too many decode_bit() calls |