답안 #576781

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
576781 2022-06-13T13:25:15 Z zaneyu 저장 (Saveit) (IOI10_saveit) C++14
75 / 100
208 ms 11296 KB
#include "grader.h"
#include "encoder.h"

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,int>
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
namespace {
    vector<int> v[1005],g[1005];
    int dist[1005];
    void send(int x){
        REP(i,10){
            encode_bit((x>>(9-i))&1);
        }
    }
    int par[1005];
    bool vis[1005];
    void dfs(int u,int p){
        par[u]=p;
        vis[u]=1;
        for(int x:v[u]){
            if(!vis[x]) dfs(x,u);
        }
    }
}
void encode(int nv, int nh, int ne, int *v1, int *v2){
    REP(i,ne){
        v[v1[i]].pb(v2[i]);
        v[v2[i]].pb(v1[i]);
    }
    dfs(0,-1);
    REP1(i,nv-1){
        send(par[i]);
    }
    vector<pii> eds;
    vector<int> vv;
    REP(i,nh){
        REP(j,nv) dist[j]=1e9;
        dist[i]=0;
        queue<int> q;
        q.push(i);
        while(sz(q)){
            int z=q.front();
            q.pop();
            for(int x:v[z]){
                if(dist[x]>dist[z]+1){
                    g[z].pb(x);
                    dist[x]=dist[z]+1;
                    q.push(x);
                }
            }
        }
        send(dist[0]);
        REP1(j,nv-1){
            vv.pb(1+dist[j]-dist[par[j]]);
        }
    }   
    while(sz(vv)%3) vv.pb(0);
    REP(i,sz(vv)/3){
        int x=vv[i*3]+vv[i*3+1]*3+vv[i*3+2]*9;
        REP(j,5) encode_bit((x>>(4-j))&1);
    }
}
#include "grader.h"
#include "decoder.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,int>
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
namespace {
int get(){
    int x=0;
    REP(i,10){
        x=x*2+decode_bit();
    }
    return x;
}
vector<int> v[1005];
int par[1005];
int ans[1005];
int df[2005];
void dfs(int u){
    for(int x:v[u]){
        ans[x]=ans[u]+df[x]-1;
        dfs(x);
    }
}
}
void decode(int nv, int nh) {
    REP1(i,nv-1){
        par[i]=get();
        v[par[i]].pb(i);
    }
    vector<int> rts;
    REP(i,nh) rts.pb(get());
    vector<int> dff;
    REP(i,((nv-1)*nh+2)/3){
        int x=0;
        REP(i,5){
            x=x*2+decode_bit();
        }
        REP(j,3){
            dff.pb(x%3);
            x/=3;
        }
    }
    reverse(ALL(dff));
    REP(i,nh){
        ans[0]=rts[i];
        int it=1;
        REP1(j,nv-1){
            df[j]=dff.back(),dff.pop_back();
        }
        dfs(0);
        REP(j,nv) hops(i,j,ans[j]); 
    }
}

Compilation message

decoder.cpp: In function 'void decode(int, int)':
decoder.cpp:67:13: warning: unused variable 'it' [-Wunused-variable]
   67 |         int it=1;
      |             ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 208 ms 11296 KB Output is partially correct - 70290 call(s) of encode_bit()
2 Correct 2 ms 4604 KB Output is correct - 90 call(s) of encode_bit()
3 Correct 20 ms 5876 KB Output is correct - 63290 call(s) of encode_bit()
4 Correct 2 ms 4612 KB Output is correct - 125 call(s) of encode_bit()
5 Correct 24 ms 6152 KB Output is correct - 63290 call(s) of encode_bit()
6 Correct 25 ms 6328 KB Output is partially correct - 70290 call(s) of encode_bit()
7 Correct 38 ms 6672 KB Output is partially correct - 70290 call(s) of encode_bit()
8 Correct 20 ms 6268 KB Output is correct - 67560 call(s) of encode_bit()
9 Correct 25 ms 6272 KB Output is partially correct - 70290 call(s) of encode_bit()
10 Correct 25 ms 6248 KB Output is partially correct - 70290 call(s) of encode_bit()
11 Correct 28 ms 6356 KB Output is partially correct - 70290 call(s) of encode_bit()
12 Correct 20 ms 6200 KB Output is partially correct - 70290 call(s) of encode_bit()
13 Correct 51 ms 6816 KB Output is partially correct - 70290 call(s) of encode_bit()
14 Correct 25 ms 6272 KB Output is partially correct - 70290 call(s) of encode_bit()
15 Correct 23 ms 6404 KB Output is partially correct - 70290 call(s) of encode_bit()
16 Correct 41 ms 6716 KB Output is partially correct - 70290 call(s) of encode_bit()
17 Correct 43 ms 6696 KB Output is partially correct - 70290 call(s) of encode_bit()
18 Correct 65 ms 6912 KB Output is partially correct - 70290 call(s) of encode_bit()
19 Correct 32 ms 6504 KB Output is partially correct - 70290 call(s) of encode_bit()
20 Correct 53 ms 7192 KB Output is partially correct - 70290 call(s) of encode_bit()
21 Correct 70 ms 7260 KB Output is partially correct - 70290 call(s) of encode_bit()
22 Correct 47 ms 6868 KB Output is partially correct - 70290 call(s) of encode_bit()
23 Correct 63 ms 7536 KB Output is partially correct - 70290 call(s) of encode_bit()
# 결과 실행 시간 메모리 Grader output
1 Correct 208 ms 11296 KB Output is partially correct - 70290 call(s) of encode_bit()
2 Correct 2 ms 4604 KB Output is correct - 90 call(s) of encode_bit()
3 Correct 20 ms 5876 KB Output is correct - 63290 call(s) of encode_bit()
4 Correct 2 ms 4612 KB Output is correct - 125 call(s) of encode_bit()
5 Correct 24 ms 6152 KB Output is correct - 63290 call(s) of encode_bit()
6 Correct 25 ms 6328 KB Output is partially correct - 70290 call(s) of encode_bit()
7 Correct 38 ms 6672 KB Output is partially correct - 70290 call(s) of encode_bit()
8 Correct 20 ms 6268 KB Output is correct - 67560 call(s) of encode_bit()
9 Correct 25 ms 6272 KB Output is partially correct - 70290 call(s) of encode_bit()
10 Correct 25 ms 6248 KB Output is partially correct - 70290 call(s) of encode_bit()
11 Correct 28 ms 6356 KB Output is partially correct - 70290 call(s) of encode_bit()
12 Correct 20 ms 6200 KB Output is partially correct - 70290 call(s) of encode_bit()
13 Correct 51 ms 6816 KB Output is partially correct - 70290 call(s) of encode_bit()
14 Correct 25 ms 6272 KB Output is partially correct - 70290 call(s) of encode_bit()
15 Correct 23 ms 6404 KB Output is partially correct - 70290 call(s) of encode_bit()
16 Correct 41 ms 6716 KB Output is partially correct - 70290 call(s) of encode_bit()
17 Correct 43 ms 6696 KB Output is partially correct - 70290 call(s) of encode_bit()
18 Correct 65 ms 6912 KB Output is partially correct - 70290 call(s) of encode_bit()
19 Correct 32 ms 6504 KB Output is partially correct - 70290 call(s) of encode_bit()
20 Correct 53 ms 7192 KB Output is partially correct - 70290 call(s) of encode_bit()
21 Correct 70 ms 7260 KB Output is partially correct - 70290 call(s) of encode_bit()
22 Correct 47 ms 6868 KB Output is partially correct - 70290 call(s) of encode_bit()
23 Correct 63 ms 7536 KB Output is partially correct - 70290 call(s) of encode_bit()
# 결과 실행 시간 메모리 Grader output
1 Correct 208 ms 11296 KB Output is partially correct - 70290 call(s) of encode_bit()
2 Correct 2 ms 4604 KB Output is correct - 90 call(s) of encode_bit()
3 Correct 20 ms 5876 KB Output is correct - 63290 call(s) of encode_bit()
4 Correct 2 ms 4612 KB Output is correct - 125 call(s) of encode_bit()
5 Correct 24 ms 6152 KB Output is correct - 63290 call(s) of encode_bit()
6 Correct 25 ms 6328 KB Output is partially correct - 70290 call(s) of encode_bit()
7 Correct 38 ms 6672 KB Output is partially correct - 70290 call(s) of encode_bit()
8 Correct 20 ms 6268 KB Output is correct - 67560 call(s) of encode_bit()
9 Correct 25 ms 6272 KB Output is partially correct - 70290 call(s) of encode_bit()
10 Correct 25 ms 6248 KB Output is partially correct - 70290 call(s) of encode_bit()
11 Correct 28 ms 6356 KB Output is partially correct - 70290 call(s) of encode_bit()
12 Correct 20 ms 6200 KB Output is partially correct - 70290 call(s) of encode_bit()
13 Correct 51 ms 6816 KB Output is partially correct - 70290 call(s) of encode_bit()
14 Correct 25 ms 6272 KB Output is partially correct - 70290 call(s) of encode_bit()
15 Correct 23 ms 6404 KB Output is partially correct - 70290 call(s) of encode_bit()
16 Correct 41 ms 6716 KB Output is partially correct - 70290 call(s) of encode_bit()
17 Correct 43 ms 6696 KB Output is partially correct - 70290 call(s) of encode_bit()
18 Correct 65 ms 6912 KB Output is partially correct - 70290 call(s) of encode_bit()
19 Correct 32 ms 6504 KB Output is partially correct - 70290 call(s) of encode_bit()
20 Correct 53 ms 7192 KB Output is partially correct - 70290 call(s) of encode_bit()
21 Correct 70 ms 7260 KB Output is partially correct - 70290 call(s) of encode_bit()
22 Correct 47 ms 6868 KB Output is partially correct - 70290 call(s) of encode_bit()
23 Correct 63 ms 7536 KB Output is partially correct - 70290 call(s) of encode_bit()
# 결과 실행 시간 메모리 Grader output
1 Correct 208 ms 11296 KB Output is partially correct - 70290 call(s) of encode_bit()
2 Correct 2 ms 4604 KB Output is correct - 90 call(s) of encode_bit()
3 Correct 20 ms 5876 KB Output is correct - 63290 call(s) of encode_bit()
4 Correct 2 ms 4612 KB Output is correct - 125 call(s) of encode_bit()
5 Correct 24 ms 6152 KB Output is correct - 63290 call(s) of encode_bit()
6 Correct 25 ms 6328 KB Output is partially correct - 70290 call(s) of encode_bit()
7 Correct 38 ms 6672 KB Output is partially correct - 70290 call(s) of encode_bit()
8 Correct 20 ms 6268 KB Output is correct - 67560 call(s) of encode_bit()
9 Correct 25 ms 6272 KB Output is partially correct - 70290 call(s) of encode_bit()
10 Correct 25 ms 6248 KB Output is partially correct - 70290 call(s) of encode_bit()
11 Correct 28 ms 6356 KB Output is partially correct - 70290 call(s) of encode_bit()
12 Correct 20 ms 6200 KB Output is partially correct - 70290 call(s) of encode_bit()
13 Correct 51 ms 6816 KB Output is partially correct - 70290 call(s) of encode_bit()
14 Correct 25 ms 6272 KB Output is partially correct - 70290 call(s) of encode_bit()
15 Correct 23 ms 6404 KB Output is partially correct - 70290 call(s) of encode_bit()
16 Correct 41 ms 6716 KB Output is partially correct - 70290 call(s) of encode_bit()
17 Correct 43 ms 6696 KB Output is partially correct - 70290 call(s) of encode_bit()
18 Correct 65 ms 6912 KB Output is partially correct - 70290 call(s) of encode_bit()
19 Correct 32 ms 6504 KB Output is partially correct - 70290 call(s) of encode_bit()
20 Correct 53 ms 7192 KB Output is partially correct - 70290 call(s) of encode_bit()
21 Correct 70 ms 7260 KB Output is partially correct - 70290 call(s) of encode_bit()
22 Correct 47 ms 6868 KB Output is partially correct - 70290 call(s) of encode_bit()
23 Correct 63 ms 7536 KB Output is partially correct - 70290 call(s) of encode_bit()