# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
565345 |
2022-05-20T17:56:04 Z |
shrimb |
Saveit (IOI10_saveit) |
C++17 |
|
201 ms |
14012 KB |
#include "grader.h"
#include "encoder.h"
#include"bits/stdc++.h"
using namespace std;
void encode(int n, int h, int p, int *v1, int *v2){
vector<int> adj[n];
for (int i = 0 ; i < p ; i++) {
adj[v1[i]].push_back(v2[i]);
adj[v2[i]].push_back(v1[i]);
}
int par[n];
{
queue<int> q;
vector<bool> vis(n);
q.push(0);
while (q.size()) {
auto cur = q.front();
q.pop();
for (int j : adj[cur]) {
if (!vis[j]) {
vis[j] = 1;
par[j] = cur;
q.push(j);
}
}
}
}
auto sendnum = [&](int x) {
for (int k = 0 ; k < 10 ; k++) {
encode_bit(!!(x & (1 << k)));
}
};
for (int i = 1 ; i < n ; i++) sendnum(par[i]);
for (int i = 1 ; i < h ; i++) {
queue<int> q;
vector<int> dis(n, -1);
dis[i] = 0;
q.push(i);
while (q.size()) {
auto cur = q.front();
q.pop();
for (int j : adj[cur]) {
if (dis[j] == -1) {
dis[j] = dis[cur] + 1;
q.push(j);
}
}
}
for (int i = 1 ; i < n ; i++) {
int x = dis[i] - dis[par[i]];
if (x == 1) encode_bit(1), encode_bit(1);
else if (x == -1) encode_bit(0);
else encode_bit(1), encode_bit(0);
}
}
}
#include "grader.h"
#include "decoder.h"
#include "bits/stdc++.h"
using namespace std;
void decode(int n, int h) {
vector<int> adj[n];
int par[n];
auto getnum = [&]() {
int ret = 0;
for (int k = 0 ; k < 10 ; k++) {
ret |= (1 << k)*decode_bit();
}
return ret;
};
for (int i = 1 ; i < n ; i++) {
int x = getnum();
par[i] = x;
adj[i].push_back(x);
adj[x].push_back(i);
}
{
queue<int> q;
vector<int> dis(n, -1);
dis[0] = 0;
q.push(0);
while (q.size()) {
auto cur = q.front();
q.pop();
for (int j : adj[cur]) {
if (dis[j] == -1) {
dis[j] = dis[cur] + 1;
q.push(j);
}
}
}
for (int i = 0 ; i < n ; i++) {
hops(0, i, dis[i]);
}
}
int w[n][n];
for (int i = 1 ; i < h ; i++) {
for (int j = 1 ; j < n ; j++) {
int v;
if (decode_bit()) {
if (decode_bit()) v = 1;
else v = 0;
} else {
v = -1;
}
w[par[j]][j] = v;
w[j][par[j]] = -v;
}
queue<int> q;
vector<int> dis(n, -1e9);
dis[i] = 0;
q.push(i);
while (q.size()) {
auto cur = q.front();
q.pop();
for (int j : adj[cur]) {
if (dis[j] == -1e9) {
dis[j] = dis[cur] + w[cur][j];
q.push(j);
}
}
}
for (int j = 0 ; j < n ; j++) {
hops(i, j, dis[j]);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
201 ms |
14012 KB |
Output is partially correct - 71480 call(s) of encode_bit() |
2 |
Correct |
1 ms |
4604 KB |
Output is correct - 54 call(s) of encode_bit() |
3 |
Correct |
22 ms |
8560 KB |
Output is correct - 64408 call(s) of encode_bit() |
4 |
Correct |
2 ms |
4600 KB |
Output is correct - 68 call(s) of encode_bit() |
5 |
Correct |
29 ms |
8688 KB |
Output is correct - 64566 call(s) of encode_bit() |
6 |
Correct |
27 ms |
9532 KB |
Output is partially correct - 72297 call(s) of encode_bit() |
7 |
Correct |
45 ms |
9844 KB |
Output is partially correct - 76767 call(s) of encode_bit() |
8 |
Correct |
26 ms |
8936 KB |
Output is correct - 68729 call(s) of encode_bit() |
9 |
Correct |
26 ms |
9448 KB |
Output is partially correct - 76993 call(s) of encode_bit() |
10 |
Correct |
24 ms |
9448 KB |
Output is partially correct - 77755 call(s) of encode_bit() |
11 |
Correct |
28 ms |
9588 KB |
Output is partially correct - 75740 call(s) of encode_bit() |
12 |
Correct |
24 ms |
9192 KB |
Output is partially correct - 70243 call(s) of encode_bit() |
13 |
Correct |
44 ms |
10000 KB |
Output is partially correct - 75963 call(s) of encode_bit() |
14 |
Correct |
27 ms |
9252 KB |
Output is correct - 69480 call(s) of encode_bit() |
15 |
Correct |
24 ms |
9344 KB |
Output is correct - 64917 call(s) of encode_bit() |
16 |
Correct |
43 ms |
9864 KB |
Output is correct - 69749 call(s) of encode_bit() |
17 |
Correct |
38 ms |
9704 KB |
Output is correct - 69060 call(s) of encode_bit() |
18 |
Correct |
55 ms |
9988 KB |
Output is partially correct - 71283 call(s) of encode_bit() |
19 |
Correct |
34 ms |
9744 KB |
Output is partially correct - 74255 call(s) of encode_bit() |
20 |
Correct |
59 ms |
10204 KB |
Output is partially correct - 71654 call(s) of encode_bit() |
21 |
Correct |
67 ms |
10508 KB |
Output is partially correct - 72760 call(s) of encode_bit() |
22 |
Correct |
47 ms |
9924 KB |
Output is partially correct - 77283 call(s) of encode_bit() |
23 |
Correct |
69 ms |
10728 KB |
Output is partially correct - 75099 call(s) of encode_bit() |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
201 ms |
14012 KB |
Output is partially correct - 71480 call(s) of encode_bit() |
2 |
Correct |
1 ms |
4604 KB |
Output is correct - 54 call(s) of encode_bit() |
3 |
Correct |
22 ms |
8560 KB |
Output is correct - 64408 call(s) of encode_bit() |
4 |
Correct |
2 ms |
4600 KB |
Output is correct - 68 call(s) of encode_bit() |
5 |
Correct |
29 ms |
8688 KB |
Output is correct - 64566 call(s) of encode_bit() |
6 |
Correct |
27 ms |
9532 KB |
Output is partially correct - 72297 call(s) of encode_bit() |
7 |
Correct |
45 ms |
9844 KB |
Output is partially correct - 76767 call(s) of encode_bit() |
8 |
Correct |
26 ms |
8936 KB |
Output is correct - 68729 call(s) of encode_bit() |
9 |
Correct |
26 ms |
9448 KB |
Output is partially correct - 76993 call(s) of encode_bit() |
10 |
Correct |
24 ms |
9448 KB |
Output is partially correct - 77755 call(s) of encode_bit() |
11 |
Correct |
28 ms |
9588 KB |
Output is partially correct - 75740 call(s) of encode_bit() |
12 |
Correct |
24 ms |
9192 KB |
Output is partially correct - 70243 call(s) of encode_bit() |
13 |
Correct |
44 ms |
10000 KB |
Output is partially correct - 75963 call(s) of encode_bit() |
14 |
Correct |
27 ms |
9252 KB |
Output is correct - 69480 call(s) of encode_bit() |
15 |
Correct |
24 ms |
9344 KB |
Output is correct - 64917 call(s) of encode_bit() |
16 |
Correct |
43 ms |
9864 KB |
Output is correct - 69749 call(s) of encode_bit() |
17 |
Correct |
38 ms |
9704 KB |
Output is correct - 69060 call(s) of encode_bit() |
18 |
Correct |
55 ms |
9988 KB |
Output is partially correct - 71283 call(s) of encode_bit() |
19 |
Correct |
34 ms |
9744 KB |
Output is partially correct - 74255 call(s) of encode_bit() |
20 |
Correct |
59 ms |
10204 KB |
Output is partially correct - 71654 call(s) of encode_bit() |
21 |
Correct |
67 ms |
10508 KB |
Output is partially correct - 72760 call(s) of encode_bit() |
22 |
Correct |
47 ms |
9924 KB |
Output is partially correct - 77283 call(s) of encode_bit() |
23 |
Correct |
69 ms |
10728 KB |
Output is partially correct - 75099 call(s) of encode_bit() |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
201 ms |
14012 KB |
Output is partially correct - 71480 call(s) of encode_bit() |
2 |
Correct |
1 ms |
4604 KB |
Output is correct - 54 call(s) of encode_bit() |
3 |
Correct |
22 ms |
8560 KB |
Output is correct - 64408 call(s) of encode_bit() |
4 |
Correct |
2 ms |
4600 KB |
Output is correct - 68 call(s) of encode_bit() |
5 |
Correct |
29 ms |
8688 KB |
Output is correct - 64566 call(s) of encode_bit() |
6 |
Correct |
27 ms |
9532 KB |
Output is partially correct - 72297 call(s) of encode_bit() |
7 |
Correct |
45 ms |
9844 KB |
Output is partially correct - 76767 call(s) of encode_bit() |
8 |
Correct |
26 ms |
8936 KB |
Output is correct - 68729 call(s) of encode_bit() |
9 |
Correct |
26 ms |
9448 KB |
Output is partially correct - 76993 call(s) of encode_bit() |
10 |
Correct |
24 ms |
9448 KB |
Output is partially correct - 77755 call(s) of encode_bit() |
11 |
Correct |
28 ms |
9588 KB |
Output is partially correct - 75740 call(s) of encode_bit() |
12 |
Correct |
24 ms |
9192 KB |
Output is partially correct - 70243 call(s) of encode_bit() |
13 |
Correct |
44 ms |
10000 KB |
Output is partially correct - 75963 call(s) of encode_bit() |
14 |
Correct |
27 ms |
9252 KB |
Output is correct - 69480 call(s) of encode_bit() |
15 |
Correct |
24 ms |
9344 KB |
Output is correct - 64917 call(s) of encode_bit() |
16 |
Correct |
43 ms |
9864 KB |
Output is correct - 69749 call(s) of encode_bit() |
17 |
Correct |
38 ms |
9704 KB |
Output is correct - 69060 call(s) of encode_bit() |
18 |
Correct |
55 ms |
9988 KB |
Output is partially correct - 71283 call(s) of encode_bit() |
19 |
Correct |
34 ms |
9744 KB |
Output is partially correct - 74255 call(s) of encode_bit() |
20 |
Correct |
59 ms |
10204 KB |
Output is partially correct - 71654 call(s) of encode_bit() |
21 |
Correct |
67 ms |
10508 KB |
Output is partially correct - 72760 call(s) of encode_bit() |
22 |
Correct |
47 ms |
9924 KB |
Output is partially correct - 77283 call(s) of encode_bit() |
23 |
Correct |
69 ms |
10728 KB |
Output is partially correct - 75099 call(s) of encode_bit() |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
201 ms |
14012 KB |
Output is partially correct - 71480 call(s) of encode_bit() |
2 |
Correct |
1 ms |
4604 KB |
Output is correct - 54 call(s) of encode_bit() |
3 |
Correct |
22 ms |
8560 KB |
Output is correct - 64408 call(s) of encode_bit() |
4 |
Correct |
2 ms |
4600 KB |
Output is correct - 68 call(s) of encode_bit() |
5 |
Correct |
29 ms |
8688 KB |
Output is correct - 64566 call(s) of encode_bit() |
6 |
Correct |
27 ms |
9532 KB |
Output is partially correct - 72297 call(s) of encode_bit() |
7 |
Correct |
45 ms |
9844 KB |
Output is partially correct - 76767 call(s) of encode_bit() |
8 |
Correct |
26 ms |
8936 KB |
Output is correct - 68729 call(s) of encode_bit() |
9 |
Correct |
26 ms |
9448 KB |
Output is partially correct - 76993 call(s) of encode_bit() |
10 |
Correct |
24 ms |
9448 KB |
Output is partially correct - 77755 call(s) of encode_bit() |
11 |
Correct |
28 ms |
9588 KB |
Output is partially correct - 75740 call(s) of encode_bit() |
12 |
Correct |
24 ms |
9192 KB |
Output is partially correct - 70243 call(s) of encode_bit() |
13 |
Correct |
44 ms |
10000 KB |
Output is partially correct - 75963 call(s) of encode_bit() |
14 |
Correct |
27 ms |
9252 KB |
Output is correct - 69480 call(s) of encode_bit() |
15 |
Correct |
24 ms |
9344 KB |
Output is correct - 64917 call(s) of encode_bit() |
16 |
Correct |
43 ms |
9864 KB |
Output is correct - 69749 call(s) of encode_bit() |
17 |
Correct |
38 ms |
9704 KB |
Output is correct - 69060 call(s) of encode_bit() |
18 |
Correct |
55 ms |
9988 KB |
Output is partially correct - 71283 call(s) of encode_bit() |
19 |
Correct |
34 ms |
9744 KB |
Output is partially correct - 74255 call(s) of encode_bit() |
20 |
Correct |
59 ms |
10204 KB |
Output is partially correct - 71654 call(s) of encode_bit() |
21 |
Correct |
67 ms |
10508 KB |
Output is partially correct - 72760 call(s) of encode_bit() |
22 |
Correct |
47 ms |
9924 KB |
Output is partially correct - 77283 call(s) of encode_bit() |
23 |
Correct |
69 ms |
10728 KB |
Output is partially correct - 75099 call(s) of encode_bit() |