# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
565344 |
2022-05-20T17:54:39 Z |
shrimb |
Saveit (IOI10_saveit) |
C++17 |
|
217 ms |
14020 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 |
217 ms |
14020 KB |
Output is partially correct - 70402 call(s) of encode_bit() |
2 |
Correct |
3 ms |
4612 KB |
Output is correct - 54 call(s) of encode_bit() |
3 |
Correct |
28 ms |
8536 KB |
Output is correct - 60986 call(s) of encode_bit() |
4 |
Correct |
3 ms |
4604 KB |
Output is correct - 70 call(s) of encode_bit() |
5 |
Correct |
30 ms |
8788 KB |
Output is correct - 63441 call(s) of encode_bit() |
6 |
Correct |
31 ms |
9460 KB |
Output is partially correct - 71593 call(s) of encode_bit() |
7 |
Correct |
50 ms |
9840 KB |
Output is partially correct - 77200 call(s) of encode_bit() |
8 |
Correct |
19 ms |
8776 KB |
Output is correct - 51271 call(s) of encode_bit() |
9 |
Correct |
27 ms |
9196 KB |
Output is correct - 49156 call(s) of encode_bit() |
10 |
Correct |
24 ms |
9120 KB |
Output is correct - 48795 call(s) of encode_bit() |
11 |
Correct |
33 ms |
9256 KB |
Output is correct - 52512 call(s) of encode_bit() |
12 |
Correct |
22 ms |
9212 KB |
Output is correct - 54632 call(s) of encode_bit() |
13 |
Correct |
52 ms |
9788 KB |
Output is partially correct - 70506 call(s) of encode_bit() |
14 |
Correct |
28 ms |
9192 KB |
Output is correct - 57621 call(s) of encode_bit() |
15 |
Correct |
28 ms |
9308 KB |
Output is correct - 63702 call(s) of encode_bit() |
16 |
Correct |
56 ms |
9624 KB |
Output is correct - 62928 call(s) of encode_bit() |
17 |
Correct |
41 ms |
9700 KB |
Output is correct - 61726 call(s) of encode_bit() |
18 |
Correct |
48 ms |
9988 KB |
Output is correct - 63689 call(s) of encode_bit() |
19 |
Correct |
44 ms |
9508 KB |
Output is correct - 63697 call(s) of encode_bit() |
20 |
Correct |
56 ms |
10288 KB |
Output is correct - 69571 call(s) of encode_bit() |
21 |
Correct |
71 ms |
10424 KB |
Output is correct - 67715 call(s) of encode_bit() |
22 |
Correct |
61 ms |
10048 KB |
Output is partially correct - 74473 call(s) of encode_bit() |
23 |
Correct |
78 ms |
10632 KB |
Output is partially correct - 72871 call(s) of encode_bit() |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
217 ms |
14020 KB |
Output is partially correct - 70402 call(s) of encode_bit() |
2 |
Correct |
3 ms |
4612 KB |
Output is correct - 54 call(s) of encode_bit() |
3 |
Correct |
28 ms |
8536 KB |
Output is correct - 60986 call(s) of encode_bit() |
4 |
Correct |
3 ms |
4604 KB |
Output is correct - 70 call(s) of encode_bit() |
5 |
Correct |
30 ms |
8788 KB |
Output is correct - 63441 call(s) of encode_bit() |
6 |
Correct |
31 ms |
9460 KB |
Output is partially correct - 71593 call(s) of encode_bit() |
7 |
Correct |
50 ms |
9840 KB |
Output is partially correct - 77200 call(s) of encode_bit() |
8 |
Correct |
19 ms |
8776 KB |
Output is correct - 51271 call(s) of encode_bit() |
9 |
Correct |
27 ms |
9196 KB |
Output is correct - 49156 call(s) of encode_bit() |
10 |
Correct |
24 ms |
9120 KB |
Output is correct - 48795 call(s) of encode_bit() |
11 |
Correct |
33 ms |
9256 KB |
Output is correct - 52512 call(s) of encode_bit() |
12 |
Correct |
22 ms |
9212 KB |
Output is correct - 54632 call(s) of encode_bit() |
13 |
Correct |
52 ms |
9788 KB |
Output is partially correct - 70506 call(s) of encode_bit() |
14 |
Correct |
28 ms |
9192 KB |
Output is correct - 57621 call(s) of encode_bit() |
15 |
Correct |
28 ms |
9308 KB |
Output is correct - 63702 call(s) of encode_bit() |
16 |
Correct |
56 ms |
9624 KB |
Output is correct - 62928 call(s) of encode_bit() |
17 |
Correct |
41 ms |
9700 KB |
Output is correct - 61726 call(s) of encode_bit() |
18 |
Correct |
48 ms |
9988 KB |
Output is correct - 63689 call(s) of encode_bit() |
19 |
Correct |
44 ms |
9508 KB |
Output is correct - 63697 call(s) of encode_bit() |
20 |
Correct |
56 ms |
10288 KB |
Output is correct - 69571 call(s) of encode_bit() |
21 |
Correct |
71 ms |
10424 KB |
Output is correct - 67715 call(s) of encode_bit() |
22 |
Correct |
61 ms |
10048 KB |
Output is partially correct - 74473 call(s) of encode_bit() |
23 |
Correct |
78 ms |
10632 KB |
Output is partially correct - 72871 call(s) of encode_bit() |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
217 ms |
14020 KB |
Output is partially correct - 70402 call(s) of encode_bit() |
2 |
Correct |
3 ms |
4612 KB |
Output is correct - 54 call(s) of encode_bit() |
3 |
Correct |
28 ms |
8536 KB |
Output is correct - 60986 call(s) of encode_bit() |
4 |
Correct |
3 ms |
4604 KB |
Output is correct - 70 call(s) of encode_bit() |
5 |
Correct |
30 ms |
8788 KB |
Output is correct - 63441 call(s) of encode_bit() |
6 |
Correct |
31 ms |
9460 KB |
Output is partially correct - 71593 call(s) of encode_bit() |
7 |
Correct |
50 ms |
9840 KB |
Output is partially correct - 77200 call(s) of encode_bit() |
8 |
Correct |
19 ms |
8776 KB |
Output is correct - 51271 call(s) of encode_bit() |
9 |
Correct |
27 ms |
9196 KB |
Output is correct - 49156 call(s) of encode_bit() |
10 |
Correct |
24 ms |
9120 KB |
Output is correct - 48795 call(s) of encode_bit() |
11 |
Correct |
33 ms |
9256 KB |
Output is correct - 52512 call(s) of encode_bit() |
12 |
Correct |
22 ms |
9212 KB |
Output is correct - 54632 call(s) of encode_bit() |
13 |
Correct |
52 ms |
9788 KB |
Output is partially correct - 70506 call(s) of encode_bit() |
14 |
Correct |
28 ms |
9192 KB |
Output is correct - 57621 call(s) of encode_bit() |
15 |
Correct |
28 ms |
9308 KB |
Output is correct - 63702 call(s) of encode_bit() |
16 |
Correct |
56 ms |
9624 KB |
Output is correct - 62928 call(s) of encode_bit() |
17 |
Correct |
41 ms |
9700 KB |
Output is correct - 61726 call(s) of encode_bit() |
18 |
Correct |
48 ms |
9988 KB |
Output is correct - 63689 call(s) of encode_bit() |
19 |
Correct |
44 ms |
9508 KB |
Output is correct - 63697 call(s) of encode_bit() |
20 |
Correct |
56 ms |
10288 KB |
Output is correct - 69571 call(s) of encode_bit() |
21 |
Correct |
71 ms |
10424 KB |
Output is correct - 67715 call(s) of encode_bit() |
22 |
Correct |
61 ms |
10048 KB |
Output is partially correct - 74473 call(s) of encode_bit() |
23 |
Correct |
78 ms |
10632 KB |
Output is partially correct - 72871 call(s) of encode_bit() |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
217 ms |
14020 KB |
Output is partially correct - 70402 call(s) of encode_bit() |
2 |
Correct |
3 ms |
4612 KB |
Output is correct - 54 call(s) of encode_bit() |
3 |
Correct |
28 ms |
8536 KB |
Output is correct - 60986 call(s) of encode_bit() |
4 |
Correct |
3 ms |
4604 KB |
Output is correct - 70 call(s) of encode_bit() |
5 |
Correct |
30 ms |
8788 KB |
Output is correct - 63441 call(s) of encode_bit() |
6 |
Correct |
31 ms |
9460 KB |
Output is partially correct - 71593 call(s) of encode_bit() |
7 |
Correct |
50 ms |
9840 KB |
Output is partially correct - 77200 call(s) of encode_bit() |
8 |
Correct |
19 ms |
8776 KB |
Output is correct - 51271 call(s) of encode_bit() |
9 |
Correct |
27 ms |
9196 KB |
Output is correct - 49156 call(s) of encode_bit() |
10 |
Correct |
24 ms |
9120 KB |
Output is correct - 48795 call(s) of encode_bit() |
11 |
Correct |
33 ms |
9256 KB |
Output is correct - 52512 call(s) of encode_bit() |
12 |
Correct |
22 ms |
9212 KB |
Output is correct - 54632 call(s) of encode_bit() |
13 |
Correct |
52 ms |
9788 KB |
Output is partially correct - 70506 call(s) of encode_bit() |
14 |
Correct |
28 ms |
9192 KB |
Output is correct - 57621 call(s) of encode_bit() |
15 |
Correct |
28 ms |
9308 KB |
Output is correct - 63702 call(s) of encode_bit() |
16 |
Correct |
56 ms |
9624 KB |
Output is correct - 62928 call(s) of encode_bit() |
17 |
Correct |
41 ms |
9700 KB |
Output is correct - 61726 call(s) of encode_bit() |
18 |
Correct |
48 ms |
9988 KB |
Output is correct - 63689 call(s) of encode_bit() |
19 |
Correct |
44 ms |
9508 KB |
Output is correct - 63697 call(s) of encode_bit() |
20 |
Correct |
56 ms |
10288 KB |
Output is correct - 69571 call(s) of encode_bit() |
21 |
Correct |
71 ms |
10424 KB |
Output is correct - 67715 call(s) of encode_bit() |
22 |
Correct |
61 ms |
10048 KB |
Output is partially correct - 74473 call(s) of encode_bit() |
23 |
Correct |
78 ms |
10632 KB |
Output is partially correct - 72871 call(s) of encode_bit() |