# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
566126 |
2022-05-21T20:51:13 Z |
RealSnake |
Saveit (IOI10_saveit) |
C++14 |
|
218 ms |
12396 KB |
#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]);
}
set<int> s;
s.insert(0);
int par[n] = {};
par[0] = 1;
vector<int> v2[n];
while(s.size()) {
int x = *s.begin();
s.erase(s.begin());
for(int i : v[x]) {
if(!par[i]) {
v2[x].push_back(i);
par[i] = x + 1;
s.insert(i);
}
}
sort(v2[x].begin(), v2[x].end());
}
for(int i = 1; i < n; i++) {
int x = par[i] - 1;
for(int j = 0; j < 10; j++)
encode_bit(((x & (1 << j)) > 0));
}
int ans[n][h];
for(int i = 0; i < n; i++) {
for(int j = 0; j < h; j++)
ans[i][j] = 1e9;
}
set<pair<int, pair<int, int>>> ss;
for(int i = 0; i < h; i++) {
ss.insert({0, {i, i}});
ans[i][i] = 0;
}
while(ss.size()) {
pair<int, pair<int, int>> p = *ss.begin();
ss.erase(ss.begin());
int x = p.second.first, hub = p.second.second;
int cost = p.first;
if(cost > ans[x][hub])
continue;
for(int i : v[x]) {
if(cost + 1 < ans[i][hub]) {
ans[i][hub] = cost + 1;
ss.insert({cost + 1, {i, hub}});
}
}
}
for(int i = 0; i < h; i++) {
int x = ans[0][i];
for(int j = 0; j < 10; j++)
encode_bit(((x & (1 << j)) > 0));
s.insert(0);
while(s.size()) {
x = *s.begin();
s.erase(s.begin());
for(int j : v2[x]) {
int dif = ans[j][i] - ans[x][i];
if(dif == 0)
encode_bit(0);
else {
encode_bit(1);
if(dif == 1)
encode_bit(1);
else
encode_bit(0);
}
s.insert(j);
}
}
}
}
#include "bits/stdc++.h"
using namespace std;
#include "grader.h"
#include "decoder.h"
void decode(int n, int h) {
vector<int> v[n];
for(int i = 1; i < n; i++) {
int x = 0;
for(int j = 0; j < 10; j++) {
if(decode_bit())
x += (1 << j);
}
v[x].push_back(i);
}
for(int i = 0; i < h; i++) {
int b[n];
b[0] = 0;
for(int j = 0; j < 10; j++) {
if(decode_bit())
b[0] += (1 << j);
}
set<int> s;
s.insert(0);
while(s.size()) {
int x = *s.begin();
s.erase(s.begin());
hops(i, x, b[x]);
for(int j : v[x]) {
int dif = decode_bit();
if(dif) {
if(!decode_bit())
dif = -1;
}
b[j] = b[x] + dif;
s.insert(j);
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
218 ms |
12396 KB |
Output is correct - 65250 call(s) of encode_bit() |
2 |
Correct |
2 ms |
4604 KB |
Output is correct - 90 call(s) of encode_bit() |
3 |
Correct |
40 ms |
6496 KB |
Output is correct - 60767 call(s) of encode_bit() |
4 |
Correct |
3 ms |
4604 KB |
Output is correct - 120 call(s) of encode_bit() |
5 |
Correct |
46 ms |
7124 KB |
Output is correct - 58039 call(s) of encode_bit() |
6 |
Correct |
42 ms |
7396 KB |
Output is correct - 62792 call(s) of encode_bit() |
7 |
Correct |
60 ms |
7920 KB |
Output is correct - 52996 call(s) of encode_bit() |
8 |
Correct |
40 ms |
5736 KB |
Output is partially correct - 79080 call(s) of encode_bit() |
9 |
Correct |
36 ms |
5760 KB |
Output is partially correct - 80829 call(s) of encode_bit() |
10 |
Correct |
37 ms |
5716 KB |
Output is partially correct - 80649 call(s) of encode_bit() |
11 |
Correct |
37 ms |
5820 KB |
Output is partially correct - 78911 call(s) of encode_bit() |
12 |
Correct |
30 ms |
5624 KB |
Output is partially correct - 82278 call(s) of encode_bit() |
13 |
Correct |
70 ms |
7256 KB |
Output is correct - 60658 call(s) of encode_bit() |
14 |
Correct |
36 ms |
5712 KB |
Output is partially correct - 79684 call(s) of encode_bit() |
15 |
Correct |
46 ms |
5672 KB |
Output is partially correct - 77014 call(s) of encode_bit() |
16 |
Correct |
63 ms |
6144 KB |
Output is partially correct - 75128 call(s) of encode_bit() |
17 |
Correct |
55 ms |
6364 KB |
Output is partially correct - 75075 call(s) of encode_bit() |
18 |
Correct |
56 ms |
6740 KB |
Output is partially correct - 70702 call(s) of encode_bit() |
19 |
Correct |
47 ms |
6444 KB |
Output is correct - 65634 call(s) of encode_bit() |
20 |
Correct |
61 ms |
7432 KB |
Output is correct - 64471 call(s) of encode_bit() |
21 |
Correct |
80 ms |
7440 KB |
Output is correct - 65403 call(s) of encode_bit() |
22 |
Correct |
59 ms |
7936 KB |
Output is correct - 55642 call(s) of encode_bit() |
23 |
Correct |
82 ms |
8604 KB |
Output is correct - 57685 call(s) of encode_bit() |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
218 ms |
12396 KB |
Output is correct - 65250 call(s) of encode_bit() |
2 |
Correct |
2 ms |
4604 KB |
Output is correct - 90 call(s) of encode_bit() |
3 |
Correct |
40 ms |
6496 KB |
Output is correct - 60767 call(s) of encode_bit() |
4 |
Correct |
3 ms |
4604 KB |
Output is correct - 120 call(s) of encode_bit() |
5 |
Correct |
46 ms |
7124 KB |
Output is correct - 58039 call(s) of encode_bit() |
6 |
Correct |
42 ms |
7396 KB |
Output is correct - 62792 call(s) of encode_bit() |
7 |
Correct |
60 ms |
7920 KB |
Output is correct - 52996 call(s) of encode_bit() |
8 |
Correct |
40 ms |
5736 KB |
Output is partially correct - 79080 call(s) of encode_bit() |
9 |
Correct |
36 ms |
5760 KB |
Output is partially correct - 80829 call(s) of encode_bit() |
10 |
Correct |
37 ms |
5716 KB |
Output is partially correct - 80649 call(s) of encode_bit() |
11 |
Correct |
37 ms |
5820 KB |
Output is partially correct - 78911 call(s) of encode_bit() |
12 |
Correct |
30 ms |
5624 KB |
Output is partially correct - 82278 call(s) of encode_bit() |
13 |
Correct |
70 ms |
7256 KB |
Output is correct - 60658 call(s) of encode_bit() |
14 |
Correct |
36 ms |
5712 KB |
Output is partially correct - 79684 call(s) of encode_bit() |
15 |
Correct |
46 ms |
5672 KB |
Output is partially correct - 77014 call(s) of encode_bit() |
16 |
Correct |
63 ms |
6144 KB |
Output is partially correct - 75128 call(s) of encode_bit() |
17 |
Correct |
55 ms |
6364 KB |
Output is partially correct - 75075 call(s) of encode_bit() |
18 |
Correct |
56 ms |
6740 KB |
Output is partially correct - 70702 call(s) of encode_bit() |
19 |
Correct |
47 ms |
6444 KB |
Output is correct - 65634 call(s) of encode_bit() |
20 |
Correct |
61 ms |
7432 KB |
Output is correct - 64471 call(s) of encode_bit() |
21 |
Correct |
80 ms |
7440 KB |
Output is correct - 65403 call(s) of encode_bit() |
22 |
Correct |
59 ms |
7936 KB |
Output is correct - 55642 call(s) of encode_bit() |
23 |
Correct |
82 ms |
8604 KB |
Output is correct - 57685 call(s) of encode_bit() |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
218 ms |
12396 KB |
Output is correct - 65250 call(s) of encode_bit() |
2 |
Correct |
2 ms |
4604 KB |
Output is correct - 90 call(s) of encode_bit() |
3 |
Correct |
40 ms |
6496 KB |
Output is correct - 60767 call(s) of encode_bit() |
4 |
Correct |
3 ms |
4604 KB |
Output is correct - 120 call(s) of encode_bit() |
5 |
Correct |
46 ms |
7124 KB |
Output is correct - 58039 call(s) of encode_bit() |
6 |
Correct |
42 ms |
7396 KB |
Output is correct - 62792 call(s) of encode_bit() |
7 |
Correct |
60 ms |
7920 KB |
Output is correct - 52996 call(s) of encode_bit() |
8 |
Correct |
40 ms |
5736 KB |
Output is partially correct - 79080 call(s) of encode_bit() |
9 |
Correct |
36 ms |
5760 KB |
Output is partially correct - 80829 call(s) of encode_bit() |
10 |
Correct |
37 ms |
5716 KB |
Output is partially correct - 80649 call(s) of encode_bit() |
11 |
Correct |
37 ms |
5820 KB |
Output is partially correct - 78911 call(s) of encode_bit() |
12 |
Correct |
30 ms |
5624 KB |
Output is partially correct - 82278 call(s) of encode_bit() |
13 |
Correct |
70 ms |
7256 KB |
Output is correct - 60658 call(s) of encode_bit() |
14 |
Correct |
36 ms |
5712 KB |
Output is partially correct - 79684 call(s) of encode_bit() |
15 |
Correct |
46 ms |
5672 KB |
Output is partially correct - 77014 call(s) of encode_bit() |
16 |
Correct |
63 ms |
6144 KB |
Output is partially correct - 75128 call(s) of encode_bit() |
17 |
Correct |
55 ms |
6364 KB |
Output is partially correct - 75075 call(s) of encode_bit() |
18 |
Correct |
56 ms |
6740 KB |
Output is partially correct - 70702 call(s) of encode_bit() |
19 |
Correct |
47 ms |
6444 KB |
Output is correct - 65634 call(s) of encode_bit() |
20 |
Correct |
61 ms |
7432 KB |
Output is correct - 64471 call(s) of encode_bit() |
21 |
Correct |
80 ms |
7440 KB |
Output is correct - 65403 call(s) of encode_bit() |
22 |
Correct |
59 ms |
7936 KB |
Output is correct - 55642 call(s) of encode_bit() |
23 |
Correct |
82 ms |
8604 KB |
Output is correct - 57685 call(s) of encode_bit() |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
218 ms |
12396 KB |
Output is correct - 65250 call(s) of encode_bit() |
2 |
Correct |
2 ms |
4604 KB |
Output is correct - 90 call(s) of encode_bit() |
3 |
Correct |
40 ms |
6496 KB |
Output is correct - 60767 call(s) of encode_bit() |
4 |
Correct |
3 ms |
4604 KB |
Output is correct - 120 call(s) of encode_bit() |
5 |
Correct |
46 ms |
7124 KB |
Output is correct - 58039 call(s) of encode_bit() |
6 |
Correct |
42 ms |
7396 KB |
Output is correct - 62792 call(s) of encode_bit() |
7 |
Correct |
60 ms |
7920 KB |
Output is correct - 52996 call(s) of encode_bit() |
8 |
Correct |
40 ms |
5736 KB |
Output is partially correct - 79080 call(s) of encode_bit() |
9 |
Correct |
36 ms |
5760 KB |
Output is partially correct - 80829 call(s) of encode_bit() |
10 |
Correct |
37 ms |
5716 KB |
Output is partially correct - 80649 call(s) of encode_bit() |
11 |
Correct |
37 ms |
5820 KB |
Output is partially correct - 78911 call(s) of encode_bit() |
12 |
Correct |
30 ms |
5624 KB |
Output is partially correct - 82278 call(s) of encode_bit() |
13 |
Correct |
70 ms |
7256 KB |
Output is correct - 60658 call(s) of encode_bit() |
14 |
Correct |
36 ms |
5712 KB |
Output is partially correct - 79684 call(s) of encode_bit() |
15 |
Correct |
46 ms |
5672 KB |
Output is partially correct - 77014 call(s) of encode_bit() |
16 |
Correct |
63 ms |
6144 KB |
Output is partially correct - 75128 call(s) of encode_bit() |
17 |
Correct |
55 ms |
6364 KB |
Output is partially correct - 75075 call(s) of encode_bit() |
18 |
Correct |
56 ms |
6740 KB |
Output is partially correct - 70702 call(s) of encode_bit() |
19 |
Correct |
47 ms |
6444 KB |
Output is correct - 65634 call(s) of encode_bit() |
20 |
Correct |
61 ms |
7432 KB |
Output is correct - 64471 call(s) of encode_bit() |
21 |
Correct |
80 ms |
7440 KB |
Output is correct - 65403 call(s) of encode_bit() |
22 |
Correct |
59 ms |
7936 KB |
Output is correct - 55642 call(s) of encode_bit() |
23 |
Correct |
82 ms |
8604 KB |
Output is correct - 57685 call(s) of encode_bit() |