답안 #271236

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
271236 2020-08-18T05:18:29 Z 문홍윤(#5109) 저장 (Saveit) (IOI10_saveit) C++14
75 / 100
500 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==0)encode_bit(1), encode_bit(1);
            if(dif==1)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 0;
        return -1;
    }
    return 1;
}
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]);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 500 ms 11504 KB Output is partially correct - 72945 call(s) of encode_bit()
2 Correct 4 ms 4736 KB Output is correct - 58 call(s) of encode_bit()
3 Correct 33 ms 5528 KB Output is correct - 63775 call(s) of encode_bit()
4 Correct 4 ms 4736 KB Output is correct - 74 call(s) of encode_bit()
5 Correct 36 ms 5760 KB Output is correct - 65699 call(s) of encode_bit()
6 Correct 40 ms 5888 KB Output is partially correct - 73758 call(s) of encode_bit()
7 Correct 70 ms 6156 KB Output is partially correct - 78755 call(s) of encode_bit()
8 Correct 27 ms 5376 KB Output is correct - 61099 call(s) of encode_bit()
9 Correct 26 ms 5376 KB Output is correct - 50666 call(s) of encode_bit()
10 Correct 26 ms 5376 KB Output is correct - 50096 call(s) of encode_bit()
11 Correct 37 ms 5580 KB Output is correct - 53294 call(s) of encode_bit()
12 Correct 26 ms 5504 KB Output is correct - 55631 call(s) of encode_bit()
13 Correct 60 ms 6296 KB Output is partially correct - 72891 call(s) of encode_bit()
14 Correct 28 ms 5632 KB Output is correct - 62784 call(s) of encode_bit()
15 Correct 35 ms 5632 KB Output is correct - 64009 call(s) of encode_bit()
16 Correct 62 ms 6144 KB Output is correct - 64728 call(s) of encode_bit()
17 Correct 57 ms 6136 KB Output is correct - 64621 call(s) of encode_bit()
18 Correct 61 ms 6464 KB Output is correct - 68998 call(s) of encode_bit()
19 Correct 47 ms 6016 KB Output is partially correct - 71632 call(s) of encode_bit()
20 Correct 77 ms 6652 KB Output is partially correct - 74650 call(s) of encode_bit()
21 Correct 132 ms 6832 KB Output is partially correct - 72823 call(s) of encode_bit()
22 Correct 59 ms 6264 KB Output is partially correct - 76495 call(s) of encode_bit()
23 Correct 82 ms 6904 KB Output is partially correct - 75469 call(s) of encode_bit()
# 결과 실행 시간 메모리 Grader output
1 Correct 500 ms 11504 KB Output is partially correct - 72945 call(s) of encode_bit()
2 Correct 4 ms 4736 KB Output is correct - 58 call(s) of encode_bit()
3 Correct 33 ms 5528 KB Output is correct - 63775 call(s) of encode_bit()
4 Correct 4 ms 4736 KB Output is correct - 74 call(s) of encode_bit()
5 Correct 36 ms 5760 KB Output is correct - 65699 call(s) of encode_bit()
6 Correct 40 ms 5888 KB Output is partially correct - 73758 call(s) of encode_bit()
7 Correct 70 ms 6156 KB Output is partially correct - 78755 call(s) of encode_bit()
8 Correct 27 ms 5376 KB Output is correct - 61099 call(s) of encode_bit()
9 Correct 26 ms 5376 KB Output is correct - 50666 call(s) of encode_bit()
10 Correct 26 ms 5376 KB Output is correct - 50096 call(s) of encode_bit()
11 Correct 37 ms 5580 KB Output is correct - 53294 call(s) of encode_bit()
12 Correct 26 ms 5504 KB Output is correct - 55631 call(s) of encode_bit()
13 Correct 60 ms 6296 KB Output is partially correct - 72891 call(s) of encode_bit()
14 Correct 28 ms 5632 KB Output is correct - 62784 call(s) of encode_bit()
15 Correct 35 ms 5632 KB Output is correct - 64009 call(s) of encode_bit()
16 Correct 62 ms 6144 KB Output is correct - 64728 call(s) of encode_bit()
17 Correct 57 ms 6136 KB Output is correct - 64621 call(s) of encode_bit()
18 Correct 61 ms 6464 KB Output is correct - 68998 call(s) of encode_bit()
19 Correct 47 ms 6016 KB Output is partially correct - 71632 call(s) of encode_bit()
20 Correct 77 ms 6652 KB Output is partially correct - 74650 call(s) of encode_bit()
21 Correct 132 ms 6832 KB Output is partially correct - 72823 call(s) of encode_bit()
22 Correct 59 ms 6264 KB Output is partially correct - 76495 call(s) of encode_bit()
23 Correct 82 ms 6904 KB Output is partially correct - 75469 call(s) of encode_bit()
# 결과 실행 시간 메모리 Grader output
1 Correct 500 ms 11504 KB Output is partially correct - 72945 call(s) of encode_bit()
2 Correct 4 ms 4736 KB Output is correct - 58 call(s) of encode_bit()
3 Correct 33 ms 5528 KB Output is correct - 63775 call(s) of encode_bit()
4 Correct 4 ms 4736 KB Output is correct - 74 call(s) of encode_bit()
5 Correct 36 ms 5760 KB Output is correct - 65699 call(s) of encode_bit()
6 Correct 40 ms 5888 KB Output is partially correct - 73758 call(s) of encode_bit()
7 Correct 70 ms 6156 KB Output is partially correct - 78755 call(s) of encode_bit()
8 Correct 27 ms 5376 KB Output is correct - 61099 call(s) of encode_bit()
9 Correct 26 ms 5376 KB Output is correct - 50666 call(s) of encode_bit()
10 Correct 26 ms 5376 KB Output is correct - 50096 call(s) of encode_bit()
11 Correct 37 ms 5580 KB Output is correct - 53294 call(s) of encode_bit()
12 Correct 26 ms 5504 KB Output is correct - 55631 call(s) of encode_bit()
13 Correct 60 ms 6296 KB Output is partially correct - 72891 call(s) of encode_bit()
14 Correct 28 ms 5632 KB Output is correct - 62784 call(s) of encode_bit()
15 Correct 35 ms 5632 KB Output is correct - 64009 call(s) of encode_bit()
16 Correct 62 ms 6144 KB Output is correct - 64728 call(s) of encode_bit()
17 Correct 57 ms 6136 KB Output is correct - 64621 call(s) of encode_bit()
18 Correct 61 ms 6464 KB Output is correct - 68998 call(s) of encode_bit()
19 Correct 47 ms 6016 KB Output is partially correct - 71632 call(s) of encode_bit()
20 Correct 77 ms 6652 KB Output is partially correct - 74650 call(s) of encode_bit()
21 Correct 132 ms 6832 KB Output is partially correct - 72823 call(s) of encode_bit()
22 Correct 59 ms 6264 KB Output is partially correct - 76495 call(s) of encode_bit()
23 Correct 82 ms 6904 KB Output is partially correct - 75469 call(s) of encode_bit()
# 결과 실행 시간 메모리 Grader output
1 Correct 500 ms 11504 KB Output is partially correct - 72945 call(s) of encode_bit()
2 Correct 4 ms 4736 KB Output is correct - 58 call(s) of encode_bit()
3 Correct 33 ms 5528 KB Output is correct - 63775 call(s) of encode_bit()
4 Correct 4 ms 4736 KB Output is correct - 74 call(s) of encode_bit()
5 Correct 36 ms 5760 KB Output is correct - 65699 call(s) of encode_bit()
6 Correct 40 ms 5888 KB Output is partially correct - 73758 call(s) of encode_bit()
7 Correct 70 ms 6156 KB Output is partially correct - 78755 call(s) of encode_bit()
8 Correct 27 ms 5376 KB Output is correct - 61099 call(s) of encode_bit()
9 Correct 26 ms 5376 KB Output is correct - 50666 call(s) of encode_bit()
10 Correct 26 ms 5376 KB Output is correct - 50096 call(s) of encode_bit()
11 Correct 37 ms 5580 KB Output is correct - 53294 call(s) of encode_bit()
12 Correct 26 ms 5504 KB Output is correct - 55631 call(s) of encode_bit()
13 Correct 60 ms 6296 KB Output is partially correct - 72891 call(s) of encode_bit()
14 Correct 28 ms 5632 KB Output is correct - 62784 call(s) of encode_bit()
15 Correct 35 ms 5632 KB Output is correct - 64009 call(s) of encode_bit()
16 Correct 62 ms 6144 KB Output is correct - 64728 call(s) of encode_bit()
17 Correct 57 ms 6136 KB Output is correct - 64621 call(s) of encode_bit()
18 Correct 61 ms 6464 KB Output is correct - 68998 call(s) of encode_bit()
19 Correct 47 ms 6016 KB Output is partially correct - 71632 call(s) of encode_bit()
20 Correct 77 ms 6652 KB Output is partially correct - 74650 call(s) of encode_bit()
21 Correct 132 ms 6832 KB Output is partially correct - 72823 call(s) of encode_bit()
22 Correct 59 ms 6264 KB Output is partially correct - 76495 call(s) of encode_bit()
23 Correct 82 ms 6904 KB Output is partially correct - 75469 call(s) of encode_bit()