# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
578030 |
2022-06-15T19:24:22 Z |
2fat2code |
Saveit (IOI10_saveit) |
C++17 |
|
269 ms |
10788 KB |
#include "grader.h"
#include "encoder.h"
#include <bits/stdc++.h>
using namespace std;
const int nmax = 1005;
const int hubs = 36;
int nn, hub, dist[hubs][nmax], par[nmax], lol;
vector<int>nod[nmax];
bitset<nmax>viz;
void construct(){
queue<int>q;
viz.reset();
q.push(0);
viz[0] = 1;
while(q.size()){
auto it = q.front();
q.pop();
for(auto it1 : nod[it]){
if(!viz[it1]){
viz[it1] = 1;
par[it1] = it;
q.push(it1);
}
}
}
for(int i=1;i<nn;i++){
for(int j=0;j<=9;j++){
if(par[i] & (1 << j)) encode_bit(1);
else encode_bit(0);
}
lol += 10;
}
for(int i=1;i<nn;i++){
for(int j=0;j<hub;j+=3){
int curr = 0;
if(dist[j][i] == dist[j][par[i]]){
curr += 1;
}
else if(dist[j][i] > dist[j][par[i]]){
curr += 2;
}
curr *= 3;
if(j + 1 <= hub - 1){
if(dist[j+1][i] == dist[j+1][par[i]]){
curr += 1;
}
else if(dist[j+1][i] > dist[j+1][par[i]]){
curr += 2;
}
}
curr *= 3;
if(j + 2 <= hub - 1){
if(dist[j+2][i] == dist[j+2][par[i]]){
curr += 1;
}
else if(dist[j+2][i] > dist[j+2][par[i]]){
curr += 2;
}
}
for(int t=0;t<5;t++){
encode_bit(curr % 2);
curr /= 2;
}
lol += 5;
}
}
//cout << lol << '\n';
}
void encode(int n, int h, int m, int v1[], int v2[]){
nn = n; hub = h;
for(int i=0;i<m;i++){
nod[v1[i]].push_back(v2[i]);
nod[v2[i]].push_back(v1[i]);
}
for(int i=0;i<h;i++){
queue<int>q;
viz.reset();
q.push(i);
viz[i] = 1;
while(q.size()){
auto it = q.front();
q.pop();
for(auto it1 : nod[it]){
if(!viz[it1]){
dist[i][it1] = dist[i][it] + 1;
viz[it1] = 1;
q.push(it1);
}
}
}
}
construct();
}
#include "grader.h"
#include "decoder.h"
#include <bits/stdc++.h>
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
using namespace std;
const int nmax = 1005;
const int hubs = 36;
int p[nmax], dust[hubs][nmax], slava, off;
vector <int> nid[nmax];
bitset <nmax> vuz;
vector <int> bits[nmax];
void dfs(int s){
vuz[s] = 1;
for(auto it : nid[s]){
if(!vuz[it]){
dust[0][it] = dust[0][s] + 1;
dfs(it);
}
}
}
void dfs1(int s){
for(auto it : nid[s]){
int curr = 0;
for(int j=0;j<off;j+=3){
int lol = bits[it][curr] + 2*bits[it][curr+1] + 4*bits[it][curr+2] + 8*bits[it][curr+3] + 16*bits[it][curr+4];
curr += 5;
if(j + 2 < off){
int suka = lol % 3;
if(suka == 0){
dust[j+2][it] = dust[j+2][s] - 1;
}
else if(suka == 1) dust[j+2][it] = dust[j+2][s];
else if(suka == 2){
dust[j+2][it] = dust[j+2][s] + 1;
}
}
lol /= 3;
if(j + 1 < off){
int suka = lol % 3;
if(suka == 0){
dust[j+1][it] = dust[j+1][s] - 1;
}
else if(suka == 1) dust[j+1][it] = dust[j+1][s];
else if(suka == 2){
dust[j+1][it] = dust[j+1][s] + 1;
}
}
lol /= 3;
if(j < off){
int suka = lol % 3;
if(suka == 0){
dust[j][it] = dust[j][s] - 1;
}
else if(suka == 1) dust[j][it] = dust[j][s];
else if(suka == 2){
dust[j][it] = dust[j][s] + 1;
}
}
lol /= 3;
}
dfs1(it);
}
}
void decode(int n, int h) {
off = h;
for(int i=1;i<n;i++){
for(int j=0;j<=9;j++){
int heh = decode_bit();
p[i] += heh * (1 << j);
}
slava += 10;
}
for(int i=1;i<n;i++){
nid[p[i]].push_back(i);
}
for(int i=1;i<n;i++){
for(int j=0;j<h;j+=3){
bits[i].push_back(decode_bit());
bits[i].push_back(decode_bit());
bits[i].push_back(decode_bit());
bits[i].push_back(decode_bit());
bits[i].push_back(decode_bit());
slava += 5;
}
}
dfs(0);
for(int i=0;i<h;i++) dust[i][0] = dust[0][i];
dfs1(0);
for(int i=0;i<h;i++){
for(int j=0;j<n;j++){
hops(i, j, dust[i][j]);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
269 ms |
10788 KB |
Output is correct - 69930 call(s) of encode_bit() |
2 |
Correct |
2 ms |
4604 KB |
Output is correct - 60 call(s) of encode_bit() |
3 |
Correct |
23 ms |
5764 KB |
Output is correct - 62930 call(s) of encode_bit() |
4 |
Correct |
3 ms |
4604 KB |
Output is correct - 80 call(s) of encode_bit() |
5 |
Correct |
25 ms |
6004 KB |
Output is correct - 62930 call(s) of encode_bit() |
6 |
Correct |
26 ms |
6152 KB |
Output is correct - 69930 call(s) of encode_bit() |
7 |
Correct |
38 ms |
6400 KB |
Output is correct - 69930 call(s) of encode_bit() |
8 |
Correct |
25 ms |
5832 KB |
Output is correct - 67200 call(s) of encode_bit() |
9 |
Correct |
28 ms |
5972 KB |
Output is correct - 69930 call(s) of encode_bit() |
10 |
Correct |
28 ms |
6020 KB |
Output is correct - 69930 call(s) of encode_bit() |
11 |
Correct |
25 ms |
6140 KB |
Output is correct - 69930 call(s) of encode_bit() |
12 |
Correct |
23 ms |
5892 KB |
Output is correct - 69930 call(s) of encode_bit() |
13 |
Correct |
53 ms |
6476 KB |
Output is correct - 69930 call(s) of encode_bit() |
14 |
Correct |
23 ms |
6048 KB |
Output is correct - 69930 call(s) of encode_bit() |
15 |
Correct |
24 ms |
5932 KB |
Output is correct - 69930 call(s) of encode_bit() |
16 |
Correct |
51 ms |
6360 KB |
Output is correct - 69930 call(s) of encode_bit() |
17 |
Correct |
44 ms |
6312 KB |
Output is correct - 69930 call(s) of encode_bit() |
18 |
Correct |
47 ms |
6688 KB |
Output is correct - 69930 call(s) of encode_bit() |
19 |
Correct |
33 ms |
6204 KB |
Output is correct - 69930 call(s) of encode_bit() |
20 |
Correct |
53 ms |
6936 KB |
Output is correct - 69930 call(s) of encode_bit() |
21 |
Correct |
83 ms |
7148 KB |
Output is correct - 69930 call(s) of encode_bit() |
22 |
Correct |
48 ms |
6560 KB |
Output is correct - 69930 call(s) of encode_bit() |
23 |
Correct |
68 ms |
7276 KB |
Output is correct - 69930 call(s) of encode_bit() |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
269 ms |
10788 KB |
Output is correct - 69930 call(s) of encode_bit() |
2 |
Correct |
2 ms |
4604 KB |
Output is correct - 60 call(s) of encode_bit() |
3 |
Correct |
23 ms |
5764 KB |
Output is correct - 62930 call(s) of encode_bit() |
4 |
Correct |
3 ms |
4604 KB |
Output is correct - 80 call(s) of encode_bit() |
5 |
Correct |
25 ms |
6004 KB |
Output is correct - 62930 call(s) of encode_bit() |
6 |
Correct |
26 ms |
6152 KB |
Output is correct - 69930 call(s) of encode_bit() |
7 |
Correct |
38 ms |
6400 KB |
Output is correct - 69930 call(s) of encode_bit() |
8 |
Correct |
25 ms |
5832 KB |
Output is correct - 67200 call(s) of encode_bit() |
9 |
Correct |
28 ms |
5972 KB |
Output is correct - 69930 call(s) of encode_bit() |
10 |
Correct |
28 ms |
6020 KB |
Output is correct - 69930 call(s) of encode_bit() |
11 |
Correct |
25 ms |
6140 KB |
Output is correct - 69930 call(s) of encode_bit() |
12 |
Correct |
23 ms |
5892 KB |
Output is correct - 69930 call(s) of encode_bit() |
13 |
Correct |
53 ms |
6476 KB |
Output is correct - 69930 call(s) of encode_bit() |
14 |
Correct |
23 ms |
6048 KB |
Output is correct - 69930 call(s) of encode_bit() |
15 |
Correct |
24 ms |
5932 KB |
Output is correct - 69930 call(s) of encode_bit() |
16 |
Correct |
51 ms |
6360 KB |
Output is correct - 69930 call(s) of encode_bit() |
17 |
Correct |
44 ms |
6312 KB |
Output is correct - 69930 call(s) of encode_bit() |
18 |
Correct |
47 ms |
6688 KB |
Output is correct - 69930 call(s) of encode_bit() |
19 |
Correct |
33 ms |
6204 KB |
Output is correct - 69930 call(s) of encode_bit() |
20 |
Correct |
53 ms |
6936 KB |
Output is correct - 69930 call(s) of encode_bit() |
21 |
Correct |
83 ms |
7148 KB |
Output is correct - 69930 call(s) of encode_bit() |
22 |
Correct |
48 ms |
6560 KB |
Output is correct - 69930 call(s) of encode_bit() |
23 |
Correct |
68 ms |
7276 KB |
Output is correct - 69930 call(s) of encode_bit() |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
269 ms |
10788 KB |
Output is correct - 69930 call(s) of encode_bit() |
2 |
Correct |
2 ms |
4604 KB |
Output is correct - 60 call(s) of encode_bit() |
3 |
Correct |
23 ms |
5764 KB |
Output is correct - 62930 call(s) of encode_bit() |
4 |
Correct |
3 ms |
4604 KB |
Output is correct - 80 call(s) of encode_bit() |
5 |
Correct |
25 ms |
6004 KB |
Output is correct - 62930 call(s) of encode_bit() |
6 |
Correct |
26 ms |
6152 KB |
Output is correct - 69930 call(s) of encode_bit() |
7 |
Correct |
38 ms |
6400 KB |
Output is correct - 69930 call(s) of encode_bit() |
8 |
Correct |
25 ms |
5832 KB |
Output is correct - 67200 call(s) of encode_bit() |
9 |
Correct |
28 ms |
5972 KB |
Output is correct - 69930 call(s) of encode_bit() |
10 |
Correct |
28 ms |
6020 KB |
Output is correct - 69930 call(s) of encode_bit() |
11 |
Correct |
25 ms |
6140 KB |
Output is correct - 69930 call(s) of encode_bit() |
12 |
Correct |
23 ms |
5892 KB |
Output is correct - 69930 call(s) of encode_bit() |
13 |
Correct |
53 ms |
6476 KB |
Output is correct - 69930 call(s) of encode_bit() |
14 |
Correct |
23 ms |
6048 KB |
Output is correct - 69930 call(s) of encode_bit() |
15 |
Correct |
24 ms |
5932 KB |
Output is correct - 69930 call(s) of encode_bit() |
16 |
Correct |
51 ms |
6360 KB |
Output is correct - 69930 call(s) of encode_bit() |
17 |
Correct |
44 ms |
6312 KB |
Output is correct - 69930 call(s) of encode_bit() |
18 |
Correct |
47 ms |
6688 KB |
Output is correct - 69930 call(s) of encode_bit() |
19 |
Correct |
33 ms |
6204 KB |
Output is correct - 69930 call(s) of encode_bit() |
20 |
Correct |
53 ms |
6936 KB |
Output is correct - 69930 call(s) of encode_bit() |
21 |
Correct |
83 ms |
7148 KB |
Output is correct - 69930 call(s) of encode_bit() |
22 |
Correct |
48 ms |
6560 KB |
Output is correct - 69930 call(s) of encode_bit() |
23 |
Correct |
68 ms |
7276 KB |
Output is correct - 69930 call(s) of encode_bit() |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
269 ms |
10788 KB |
Output is correct - 69930 call(s) of encode_bit() |
2 |
Correct |
2 ms |
4604 KB |
Output is correct - 60 call(s) of encode_bit() |
3 |
Correct |
23 ms |
5764 KB |
Output is correct - 62930 call(s) of encode_bit() |
4 |
Correct |
3 ms |
4604 KB |
Output is correct - 80 call(s) of encode_bit() |
5 |
Correct |
25 ms |
6004 KB |
Output is correct - 62930 call(s) of encode_bit() |
6 |
Correct |
26 ms |
6152 KB |
Output is correct - 69930 call(s) of encode_bit() |
7 |
Correct |
38 ms |
6400 KB |
Output is correct - 69930 call(s) of encode_bit() |
8 |
Correct |
25 ms |
5832 KB |
Output is correct - 67200 call(s) of encode_bit() |
9 |
Correct |
28 ms |
5972 KB |
Output is correct - 69930 call(s) of encode_bit() |
10 |
Correct |
28 ms |
6020 KB |
Output is correct - 69930 call(s) of encode_bit() |
11 |
Correct |
25 ms |
6140 KB |
Output is correct - 69930 call(s) of encode_bit() |
12 |
Correct |
23 ms |
5892 KB |
Output is correct - 69930 call(s) of encode_bit() |
13 |
Correct |
53 ms |
6476 KB |
Output is correct - 69930 call(s) of encode_bit() |
14 |
Correct |
23 ms |
6048 KB |
Output is correct - 69930 call(s) of encode_bit() |
15 |
Correct |
24 ms |
5932 KB |
Output is correct - 69930 call(s) of encode_bit() |
16 |
Correct |
51 ms |
6360 KB |
Output is correct - 69930 call(s) of encode_bit() |
17 |
Correct |
44 ms |
6312 KB |
Output is correct - 69930 call(s) of encode_bit() |
18 |
Correct |
47 ms |
6688 KB |
Output is correct - 69930 call(s) of encode_bit() |
19 |
Correct |
33 ms |
6204 KB |
Output is correct - 69930 call(s) of encode_bit() |
20 |
Correct |
53 ms |
6936 KB |
Output is correct - 69930 call(s) of encode_bit() |
21 |
Correct |
83 ms |
7148 KB |
Output is correct - 69930 call(s) of encode_bit() |
22 |
Correct |
48 ms |
6560 KB |
Output is correct - 69930 call(s) of encode_bit() |
23 |
Correct |
68 ms |
7276 KB |
Output is correct - 69930 call(s) of encode_bit() |