Submission #395007

# Submission time Handle Problem Language Result Execution time Memory
395007 2021-04-27T15:33:30 Z MarcoMeijer Saveit (IOI10_saveit) C++14
50 / 100
205 ms 10144 KB
#include "grader.h"
#include "encoder.h"
#include <bits/stdc++.h>
using namespace std;

// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e9
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second

void writeSmallInt(int x, int bits) {
    RE(i,bits) {
        bool b = false;
        if(x & (1<<i)) b = 1;
        encode_bit(b);
    }
}
int maxBits(int x) {
    int mx = 0;
    RE(i,10) if(x&(1<<i)) mx = max(mx, i+1);
    return mx;
}

void encode(int nv, int nh, int ne, int *v1, int *v2) {
    vector<vi> adj; adj.resize(nv);
    RE(i,ne) {
        adj[v1[i]].pb(v2[i]);
        adj[v2[i]].pb(v1[i]);
    }

    vector<vi> dist; dist.resize(nh);
    RE(h,nh) {
        // bfs
        dist[h].assign(nv,-1);
        queue<int> q;
        q.push(h); dist[h][h] = 0;
        while(!q.empty()) {
            int u = q.front(); q.pop();
            FOR(v,adj[u]) {
                if(dist[h][v] != -1) continue;
                dist[h][v] = dist[h][u] + 1;
                q.push(v);
            }
        }
    }

    RE(i,nh) {
        RE(j,nv) {
            int lb=0, ub=nv-1;
            RE(x,i) {
                lb = max(lb, dist[x][j] - dist[x][i]);
                ub = min(ub, dist[x][j] + dist[x][i]);
            }
            int bits = maxBits(ub-lb);
            writeSmallInt(dist[i][j] - lb, bits);
        }
    }
}
#include "grader.h"
#include "decoder.h"
#include <bits/stdc++.h>
using namespace std;

// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e9
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second

int readSmallInt(int bits) {
    int res = 0;
    RE(i,bits) {
        bool b = decode_bit();
        if(b) res |= (1<<i);
    }
    return res;
}
int maxBits2(int x) {
    int mx = 0;
    RE(i,10) if(x&(1<<i)) mx = max(mx, i+1);
    return mx;
}

void decode(int nv, int nh) {
    vector<vi> dist; dist.assign(nh, vi(nv,0));
    RE(i,nh) {
        RE(j,nv) {
            int lb=0, ub=nv-1;
            RE(x,i) {
                lb = max(lb, dist[x][j] - dist[x][i]);
                ub = min(ub, dist[x][j] + dist[x][i]);
            }
            int bits = maxBits2(ub-lb);
            dist[i][j] = lb+readSmallInt(bits);
            hops(i,j,dist[i][j]);
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 205 ms 10144 KB Output is correct - 49266 call(s) of encode_bit()
2 Correct 3 ms 4584 KB Output is correct - 32 call(s) of encode_bit()
3 Correct 37 ms 5680 KB Output is partially correct - 88654 call(s) of encode_bit()
4 Correct 4 ms 4656 KB Output is correct - 46 call(s) of encode_bit()
5 Correct 38 ms 5668 KB Output is partially correct - 73917 call(s) of encode_bit()
6 Correct 39 ms 5784 KB Output is partially correct - 84252 call(s) of encode_bit()
7 Correct 58 ms 6200 KB Output is partially correct - 83214 call(s) of encode_bit()
8 Correct 39 ms 5524 KB Output is partially correct - 81470 call(s) of encode_bit()
9 Correct 56 ms 6032 KB Output is partially correct - 136056 call(s) of encode_bit()
10 Correct 52 ms 5884 KB Output is partially correct - 123393 call(s) of encode_bit()
11 Correct 49 ms 6324 KB Output is partially correct - 134972 call(s) of encode_bit()
12 Correct 34 ms 5660 KB Output is partially correct - 84554 call(s) of encode_bit()
13 Correct 65 ms 6072 KB Output is partially correct - 73841 call(s) of encode_bit()
14 Correct 42 ms 5848 KB Output is partially correct - 100311 call(s) of encode_bit()
15 Correct 40 ms 5600 KB Output is partially correct - 71949 call(s) of encode_bit()
16 Correct 56 ms 6200 KB Output is partially correct - 80831 call(s) of encode_bit()
17 Correct 69 ms 6152 KB Output is partially correct - 84209 call(s) of encode_bit()
18 Correct 79 ms 6376 KB Output is partially correct - 83779 call(s) of encode_bit()
19 Correct 54 ms 5960 KB Output is partially correct - 90722 call(s) of encode_bit()
20 Correct 79 ms 6604 KB Output is partially correct - 70289 call(s) of encode_bit()
21 Correct 89 ms 6688 KB Output is partially correct - 76733 call(s) of encode_bit()
22 Correct 78 ms 6172 KB Output is partially correct - 83199 call(s) of encode_bit()
23 Correct 121 ms 6952 KB Output is partially correct - 78589 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 205 ms 10144 KB Output is correct - 49266 call(s) of encode_bit()
2 Correct 3 ms 4584 KB Output is correct - 32 call(s) of encode_bit()
3 Correct 37 ms 5680 KB Output is partially correct - 88654 call(s) of encode_bit()
4 Correct 4 ms 4656 KB Output is correct - 46 call(s) of encode_bit()
5 Correct 38 ms 5668 KB Output is partially correct - 73917 call(s) of encode_bit()
6 Correct 39 ms 5784 KB Output is partially correct - 84252 call(s) of encode_bit()
7 Correct 58 ms 6200 KB Output is partially correct - 83214 call(s) of encode_bit()
8 Correct 39 ms 5524 KB Output is partially correct - 81470 call(s) of encode_bit()
9 Correct 56 ms 6032 KB Output is partially correct - 136056 call(s) of encode_bit()
10 Correct 52 ms 5884 KB Output is partially correct - 123393 call(s) of encode_bit()
11 Correct 49 ms 6324 KB Output is partially correct - 134972 call(s) of encode_bit()
12 Correct 34 ms 5660 KB Output is partially correct - 84554 call(s) of encode_bit()
13 Correct 65 ms 6072 KB Output is partially correct - 73841 call(s) of encode_bit()
14 Correct 42 ms 5848 KB Output is partially correct - 100311 call(s) of encode_bit()
15 Correct 40 ms 5600 KB Output is partially correct - 71949 call(s) of encode_bit()
16 Correct 56 ms 6200 KB Output is partially correct - 80831 call(s) of encode_bit()
17 Correct 69 ms 6152 KB Output is partially correct - 84209 call(s) of encode_bit()
18 Correct 79 ms 6376 KB Output is partially correct - 83779 call(s) of encode_bit()
19 Correct 54 ms 5960 KB Output is partially correct - 90722 call(s) of encode_bit()
20 Correct 79 ms 6604 KB Output is partially correct - 70289 call(s) of encode_bit()
21 Correct 89 ms 6688 KB Output is partially correct - 76733 call(s) of encode_bit()
22 Correct 78 ms 6172 KB Output is partially correct - 83199 call(s) of encode_bit()
23 Correct 121 ms 6952 KB Output is partially correct - 78589 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 205 ms 10144 KB Output is correct - 49266 call(s) of encode_bit()
2 Correct 3 ms 4584 KB Output is correct - 32 call(s) of encode_bit()
3 Correct 37 ms 5680 KB Output is partially correct - 88654 call(s) of encode_bit()
4 Correct 4 ms 4656 KB Output is correct - 46 call(s) of encode_bit()
5 Correct 38 ms 5668 KB Output is partially correct - 73917 call(s) of encode_bit()
6 Correct 39 ms 5784 KB Output is partially correct - 84252 call(s) of encode_bit()
7 Correct 58 ms 6200 KB Output is partially correct - 83214 call(s) of encode_bit()
8 Correct 39 ms 5524 KB Output is partially correct - 81470 call(s) of encode_bit()
9 Correct 56 ms 6032 KB Output is partially correct - 136056 call(s) of encode_bit()
10 Correct 52 ms 5884 KB Output is partially correct - 123393 call(s) of encode_bit()
11 Correct 49 ms 6324 KB Output is partially correct - 134972 call(s) of encode_bit()
12 Correct 34 ms 5660 KB Output is partially correct - 84554 call(s) of encode_bit()
13 Correct 65 ms 6072 KB Output is partially correct - 73841 call(s) of encode_bit()
14 Correct 42 ms 5848 KB Output is partially correct - 100311 call(s) of encode_bit()
15 Correct 40 ms 5600 KB Output is partially correct - 71949 call(s) of encode_bit()
16 Correct 56 ms 6200 KB Output is partially correct - 80831 call(s) of encode_bit()
17 Correct 69 ms 6152 KB Output is partially correct - 84209 call(s) of encode_bit()
18 Correct 79 ms 6376 KB Output is partially correct - 83779 call(s) of encode_bit()
19 Correct 54 ms 5960 KB Output is partially correct - 90722 call(s) of encode_bit()
20 Correct 79 ms 6604 KB Output is partially correct - 70289 call(s) of encode_bit()
21 Correct 89 ms 6688 KB Output is partially correct - 76733 call(s) of encode_bit()
22 Correct 78 ms 6172 KB Output is partially correct - 83199 call(s) of encode_bit()
23 Correct 121 ms 6952 KB Output is partially correct - 78589 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 205 ms 10144 KB Output is correct - 49266 call(s) of encode_bit()
2 Correct 3 ms 4584 KB Output is correct - 32 call(s) of encode_bit()
3 Correct 37 ms 5680 KB Output is partially correct - 88654 call(s) of encode_bit()
4 Correct 4 ms 4656 KB Output is correct - 46 call(s) of encode_bit()
5 Correct 38 ms 5668 KB Output is partially correct - 73917 call(s) of encode_bit()
6 Correct 39 ms 5784 KB Output is partially correct - 84252 call(s) of encode_bit()
7 Correct 58 ms 6200 KB Output is partially correct - 83214 call(s) of encode_bit()
8 Correct 39 ms 5524 KB Output is partially correct - 81470 call(s) of encode_bit()
9 Correct 56 ms 6032 KB Output is partially correct - 136056 call(s) of encode_bit()
10 Correct 52 ms 5884 KB Output is partially correct - 123393 call(s) of encode_bit()
11 Correct 49 ms 6324 KB Output is partially correct - 134972 call(s) of encode_bit()
12 Correct 34 ms 5660 KB Output is partially correct - 84554 call(s) of encode_bit()
13 Correct 65 ms 6072 KB Output is partially correct - 73841 call(s) of encode_bit()
14 Correct 42 ms 5848 KB Output is partially correct - 100311 call(s) of encode_bit()
15 Correct 40 ms 5600 KB Output is partially correct - 71949 call(s) of encode_bit()
16 Correct 56 ms 6200 KB Output is partially correct - 80831 call(s) of encode_bit()
17 Correct 69 ms 6152 KB Output is partially correct - 84209 call(s) of encode_bit()
18 Correct 79 ms 6376 KB Output is partially correct - 83779 call(s) of encode_bit()
19 Correct 54 ms 5960 KB Output is partially correct - 90722 call(s) of encode_bit()
20 Correct 79 ms 6604 KB Output is partially correct - 70289 call(s) of encode_bit()
21 Correct 89 ms 6688 KB Output is partially correct - 76733 call(s) of encode_bit()
22 Correct 78 ms 6172 KB Output is partially correct - 83199 call(s) of encode_bit()
23 Correct 121 ms 6952 KB Output is partially correct - 78589 call(s) of encode_bit()