Submission #271225

# Submission time Handle Problem Language Result Execution time Memory
271225 2020-08-18T05:15:52 Z 문홍윤(#5109) Saveit (IOI10_saveit) C++14
50 / 100
264 ms 11504 KB
#include "grader.h"
#include "encoder.h"
#include <bits/stdc++.h>
#define eb emplace_back
using namespace std;

static int n, h, m, par[1010];
static vector<int> link[1010];

static bool ch[1010];
static void dfs(int num){
    ch[num]=true;
    for(auto i:link[num]){
        if(ch[i])continue;
        par[i]=num;
        dfs(i);
    }
}

static void enc(int num){
    for(int i=0; i<10; i++){
        if(num&(1<<i))encode_bit(1);
        else encode_bit(0);
    }
}

static int que[1010], fr, re, dis[1010];

void encode(int nv, int nh, int ne, int *v1, int *v2){
    n=nv, h=nh, m=ne;
    for(int i=0; i<m; i++){
        link[v1[i]+1].eb(v2[i]+1);
        link[v2[i]+1].eb(v1[i]+1);
    }
    dfs(1);
    for(int i=2; i<=n; i++)enc(par[i]);
    for(int i=1; i<=h; i++){
        memset(ch, 0, sizeof ch);
        que[re=1]=i;
        ch[i]=true;
        dis[i]=0;
        for(fr=1; fr<=re; fr++){
            for(auto i:link[que[fr]]){
                if(ch[i])continue;
                ch[i]=true;
                dis[i]=dis[que[fr]]+1;
                que[++re]=i;
            }
        }
        for(int j=2; j<=n; j++){
            int dif=dis[j]-dis[par[j]];
            if(dif==-1)encode_bit(1), encode_bit(0);
            if(dif==1)encode_bit(1), encode_bit(1);
            if(dif==0)encode_bit(0);
        }
    }
}
#include "grader.h"
#include "decoder.h"
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef pair<int, int> pii;

static int n, h;
static vector<pii> link[1010];
static int cnt[1010], dis[1010];

static int rd(){
    vector<int> bt;
    for(int i=0; i<10; i++)bt.eb(decode_bit());
    int ret=0;
    for(int i=9; i>=0; i--){ret*=2; ret+=bt[i];}
    return ret;
}
static int rd2(){
    if(decode_bit()){
        if(decode_bit())return 1;
        return -1;
    }
    return 0;
}
static void dfs(int num, int par){
    for(auto i:link[num]){
        if(i.F==par)continue;
        if(i.F==i.S)dis[i.F]=dis[num]+cnt[i.S];
        else dis[i.F]=dis[num]-cnt[i.S];
        dfs(i.F, num);
    }
}

void decode(int nv, int nh){
    n=nv, h=nh;
    for(int i=2; i<=n; i++){
        int j=rd();
        link[i].eb(j, i);
        link[j].eb(i, i);
    }
    for(int i=1; i<=h; i++){
        for(int j=2; j<=n; j++)cnt[j]=rd2();
        dis[i]=0;
        dfs(i, 0);
        for(int j=1; j<=n; j++)
            hops(i-1, j-1, dis[j]);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 264 ms 11504 KB Output is correct - 63888 call(s) of encode_bit()
2 Correct 3 ms 4796 KB Output is correct - 60 call(s) of encode_bit()
3 Correct 28 ms 5604 KB Output is correct - 60440 call(s) of encode_bit()
4 Correct 4 ms 4992 KB Output is correct - 70 call(s) of encode_bit()
5 Correct 31 ms 5808 KB Output is correct - 57365 call(s) of encode_bit()
6 Correct 33 ms 5760 KB Output is correct - 62202 call(s) of encode_bit()
7 Correct 47 ms 5948 KB Output is correct - 52275 call(s) of encode_bit()
8 Correct 31 ms 5692 KB Output is partially correct - 78720 call(s) of encode_bit()
9 Correct 33 ms 5796 KB Output is partially correct - 80171 call(s) of encode_bit()
10 Correct 32 ms 5644 KB Output is partially correct - 80174 call(s) of encode_bit()
11 Correct 38 ms 5792 KB Output is partially correct - 78295 call(s) of encode_bit()
12 Correct 31 ms 5760 KB Output is partially correct - 81918 call(s) of encode_bit()
13 Correct 68 ms 6348 KB Output is correct - 59063 call(s) of encode_bit()
14 Correct 32 ms 5744 KB Output is partially correct - 78621 call(s) of encode_bit()
15 Correct 32 ms 5764 KB Output is partially correct - 74906 call(s) of encode_bit()
16 Correct 60 ms 6176 KB Output is partially correct - 73533 call(s) of encode_bit()
17 Correct 49 ms 6476 KB Output is partially correct - 73478 call(s) of encode_bit()
18 Correct 60 ms 6476 KB Output is correct - 68108 call(s) of encode_bit()
19 Correct 41 ms 5888 KB Output is correct - 62757 call(s) of encode_bit()
20 Correct 78 ms 6672 KB Output is correct - 62989 call(s) of encode_bit()
21 Correct 82 ms 6776 KB Output is correct - 63452 call(s) of encode_bit()
22 Correct 49 ms 6272 KB Output is correct - 54292 call(s) of encode_bit()
23 Correct 96 ms 7000 KB Output is correct - 57575 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 264 ms 11504 KB Output is correct - 63888 call(s) of encode_bit()
2 Correct 3 ms 4796 KB Output is correct - 60 call(s) of encode_bit()
3 Correct 28 ms 5604 KB Output is correct - 60440 call(s) of encode_bit()
4 Correct 4 ms 4992 KB Output is correct - 70 call(s) of encode_bit()
5 Correct 31 ms 5808 KB Output is correct - 57365 call(s) of encode_bit()
6 Correct 33 ms 5760 KB Output is correct - 62202 call(s) of encode_bit()
7 Correct 47 ms 5948 KB Output is correct - 52275 call(s) of encode_bit()
8 Correct 31 ms 5692 KB Output is partially correct - 78720 call(s) of encode_bit()
9 Correct 33 ms 5796 KB Output is partially correct - 80171 call(s) of encode_bit()
10 Correct 32 ms 5644 KB Output is partially correct - 80174 call(s) of encode_bit()
11 Correct 38 ms 5792 KB Output is partially correct - 78295 call(s) of encode_bit()
12 Correct 31 ms 5760 KB Output is partially correct - 81918 call(s) of encode_bit()
13 Correct 68 ms 6348 KB Output is correct - 59063 call(s) of encode_bit()
14 Correct 32 ms 5744 KB Output is partially correct - 78621 call(s) of encode_bit()
15 Correct 32 ms 5764 KB Output is partially correct - 74906 call(s) of encode_bit()
16 Correct 60 ms 6176 KB Output is partially correct - 73533 call(s) of encode_bit()
17 Correct 49 ms 6476 KB Output is partially correct - 73478 call(s) of encode_bit()
18 Correct 60 ms 6476 KB Output is correct - 68108 call(s) of encode_bit()
19 Correct 41 ms 5888 KB Output is correct - 62757 call(s) of encode_bit()
20 Correct 78 ms 6672 KB Output is correct - 62989 call(s) of encode_bit()
21 Correct 82 ms 6776 KB Output is correct - 63452 call(s) of encode_bit()
22 Correct 49 ms 6272 KB Output is correct - 54292 call(s) of encode_bit()
23 Correct 96 ms 7000 KB Output is correct - 57575 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 264 ms 11504 KB Output is correct - 63888 call(s) of encode_bit()
2 Correct 3 ms 4796 KB Output is correct - 60 call(s) of encode_bit()
3 Correct 28 ms 5604 KB Output is correct - 60440 call(s) of encode_bit()
4 Correct 4 ms 4992 KB Output is correct - 70 call(s) of encode_bit()
5 Correct 31 ms 5808 KB Output is correct - 57365 call(s) of encode_bit()
6 Correct 33 ms 5760 KB Output is correct - 62202 call(s) of encode_bit()
7 Correct 47 ms 5948 KB Output is correct - 52275 call(s) of encode_bit()
8 Correct 31 ms 5692 KB Output is partially correct - 78720 call(s) of encode_bit()
9 Correct 33 ms 5796 KB Output is partially correct - 80171 call(s) of encode_bit()
10 Correct 32 ms 5644 KB Output is partially correct - 80174 call(s) of encode_bit()
11 Correct 38 ms 5792 KB Output is partially correct - 78295 call(s) of encode_bit()
12 Correct 31 ms 5760 KB Output is partially correct - 81918 call(s) of encode_bit()
13 Correct 68 ms 6348 KB Output is correct - 59063 call(s) of encode_bit()
14 Correct 32 ms 5744 KB Output is partially correct - 78621 call(s) of encode_bit()
15 Correct 32 ms 5764 KB Output is partially correct - 74906 call(s) of encode_bit()
16 Correct 60 ms 6176 KB Output is partially correct - 73533 call(s) of encode_bit()
17 Correct 49 ms 6476 KB Output is partially correct - 73478 call(s) of encode_bit()
18 Correct 60 ms 6476 KB Output is correct - 68108 call(s) of encode_bit()
19 Correct 41 ms 5888 KB Output is correct - 62757 call(s) of encode_bit()
20 Correct 78 ms 6672 KB Output is correct - 62989 call(s) of encode_bit()
21 Correct 82 ms 6776 KB Output is correct - 63452 call(s) of encode_bit()
22 Correct 49 ms 6272 KB Output is correct - 54292 call(s) of encode_bit()
23 Correct 96 ms 7000 KB Output is correct - 57575 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 264 ms 11504 KB Output is correct - 63888 call(s) of encode_bit()
2 Correct 3 ms 4796 KB Output is correct - 60 call(s) of encode_bit()
3 Correct 28 ms 5604 KB Output is correct - 60440 call(s) of encode_bit()
4 Correct 4 ms 4992 KB Output is correct - 70 call(s) of encode_bit()
5 Correct 31 ms 5808 KB Output is correct - 57365 call(s) of encode_bit()
6 Correct 33 ms 5760 KB Output is correct - 62202 call(s) of encode_bit()
7 Correct 47 ms 5948 KB Output is correct - 52275 call(s) of encode_bit()
8 Correct 31 ms 5692 KB Output is partially correct - 78720 call(s) of encode_bit()
9 Correct 33 ms 5796 KB Output is partially correct - 80171 call(s) of encode_bit()
10 Correct 32 ms 5644 KB Output is partially correct - 80174 call(s) of encode_bit()
11 Correct 38 ms 5792 KB Output is partially correct - 78295 call(s) of encode_bit()
12 Correct 31 ms 5760 KB Output is partially correct - 81918 call(s) of encode_bit()
13 Correct 68 ms 6348 KB Output is correct - 59063 call(s) of encode_bit()
14 Correct 32 ms 5744 KB Output is partially correct - 78621 call(s) of encode_bit()
15 Correct 32 ms 5764 KB Output is partially correct - 74906 call(s) of encode_bit()
16 Correct 60 ms 6176 KB Output is partially correct - 73533 call(s) of encode_bit()
17 Correct 49 ms 6476 KB Output is partially correct - 73478 call(s) of encode_bit()
18 Correct 60 ms 6476 KB Output is correct - 68108 call(s) of encode_bit()
19 Correct 41 ms 5888 KB Output is correct - 62757 call(s) of encode_bit()
20 Correct 78 ms 6672 KB Output is correct - 62989 call(s) of encode_bit()
21 Correct 82 ms 6776 KB Output is correct - 63452 call(s) of encode_bit()
22 Correct 49 ms 6272 KB Output is correct - 54292 call(s) of encode_bit()
23 Correct 96 ms 7000 KB Output is correct - 57575 call(s) of encode_bit()