답안 #394823

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
394823 2021-04-27T10:37:11 Z MarcoMeijer 저장 (Saveit) (IOI10_saveit) C++14
50 / 100
404 ms 14080 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
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

void writeSmallInt(int x) {
    RE(i,10) {
        bool b = false;
        if(x & (1<<i)) b = 1;
        encode_bit(b);
    }
}

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]);
    }
    RE(i,nv) random_shuffle(all(adj[i]), [](int x){return rng()%x;});

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

    RE(i,nv) adj[i].clear();
    FOR(p,usedEdges) adj[p.fi].pb(p.se);

    RE(i,nv) {
        writeSmallInt(adj[i].size());
        FOR(v,adj[i]) writeSmallInt(v);
    }
}
#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 res = 0;
    RE(i,10) {
        bool b = decode_bit();
        if(b) res |= (1<<i);
    }
    return res;
}

void decode(int nv, int nh) {
    // reconstruct graph
    vector<vi> adj; adj.resize(nv);
    RE(u,nv) {
        int sz = readSmallInt();
        RE(j,sz) {
            int v = readSmallInt();
            adj[u].pb(v);
            adj[v].pb(u);
        }
    }

    RE(h,nh) {
        // bfs
        vi dist; dist.assign(nv, -1);
        queue<int> q;
        q.push(h); dist[h] = 0;
        while(!q.empty()) {
            int u = q.front(); q.pop();
            hops(h,u,dist[u]);
            FOR(v,adj[u]) {
                if(dist[v] != -1) continue;
                dist[v] = dist[u] + 1;
                q.push(v);
            }
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 404 ms 14080 KB Output is partially correct - 351280 call(s) of encode_bit()
2 Correct 3 ms 4588 KB Output is correct - 120 call(s) of encode_bit()
3 Correct 27 ms 5336 KB Output is correct - 43840 call(s) of encode_bit()
4 Correct 3 ms 4600 KB Output is correct - 140 call(s) of encode_bit()
5 Correct 51 ms 6304 KB Output is partially correct - 104350 call(s) of encode_bit()
6 Correct 56 ms 6304 KB Output is partially correct - 106590 call(s) of encode_bit()
7 Correct 102 ms 8080 KB Output is partially correct - 217960 call(s) of encode_bit()
8 Correct 24 ms 5052 KB Output is correct - 28210 call(s) of encode_bit()
9 Correct 27 ms 5204 KB Output is correct - 30000 call(s) of encode_bit()
10 Correct 25 ms 5216 KB Output is correct - 29160 call(s) of encode_bit()
11 Correct 39 ms 5612 KB Output is correct - 55970 call(s) of encode_bit()
12 Correct 20 ms 4960 KB Output is correct - 19990 call(s) of encode_bit()
13 Correct 93 ms 7960 KB Output is partially correct - 183310 call(s) of encode_bit()
14 Correct 26 ms 5224 KB Output is correct - 32990 call(s) of encode_bit()
15 Correct 32 ms 5332 KB Output is correct - 33910 call(s) of encode_bit()
16 Correct 71 ms 6024 KB Output is correct - 62280 call(s) of encode_bit()
17 Correct 59 ms 6028 KB Output is correct - 67330 call(s) of encode_bit()
18 Correct 94 ms 7012 KB Output is partially correct - 119960 call(s) of encode_bit()
19 Correct 67 ms 6712 KB Output is partially correct - 124650 call(s) of encode_bit()
20 Correct 112 ms 8228 KB Output is partially correct - 182580 call(s) of encode_bit()
21 Correct 112 ms 8252 KB Output is partially correct - 179690 call(s) of encode_bit()
22 Correct 115 ms 8316 KB Output is partially correct - 222810 call(s) of encode_bit()
23 Correct 173 ms 9724 KB Output is partially correct - 266290 call(s) of encode_bit()
# 결과 실행 시간 메모리 Grader output
1 Correct 404 ms 14080 KB Output is partially correct - 351280 call(s) of encode_bit()
2 Correct 3 ms 4588 KB Output is correct - 120 call(s) of encode_bit()
3 Correct 27 ms 5336 KB Output is correct - 43840 call(s) of encode_bit()
4 Correct 3 ms 4600 KB Output is correct - 140 call(s) of encode_bit()
5 Correct 51 ms 6304 KB Output is partially correct - 104350 call(s) of encode_bit()
6 Correct 56 ms 6304 KB Output is partially correct - 106590 call(s) of encode_bit()
7 Correct 102 ms 8080 KB Output is partially correct - 217960 call(s) of encode_bit()
8 Correct 24 ms 5052 KB Output is correct - 28210 call(s) of encode_bit()
9 Correct 27 ms 5204 KB Output is correct - 30000 call(s) of encode_bit()
10 Correct 25 ms 5216 KB Output is correct - 29160 call(s) of encode_bit()
11 Correct 39 ms 5612 KB Output is correct - 55970 call(s) of encode_bit()
12 Correct 20 ms 4960 KB Output is correct - 19990 call(s) of encode_bit()
13 Correct 93 ms 7960 KB Output is partially correct - 183310 call(s) of encode_bit()
14 Correct 26 ms 5224 KB Output is correct - 32990 call(s) of encode_bit()
15 Correct 32 ms 5332 KB Output is correct - 33910 call(s) of encode_bit()
16 Correct 71 ms 6024 KB Output is correct - 62280 call(s) of encode_bit()
17 Correct 59 ms 6028 KB Output is correct - 67330 call(s) of encode_bit()
18 Correct 94 ms 7012 KB Output is partially correct - 119960 call(s) of encode_bit()
19 Correct 67 ms 6712 KB Output is partially correct - 124650 call(s) of encode_bit()
20 Correct 112 ms 8228 KB Output is partially correct - 182580 call(s) of encode_bit()
21 Correct 112 ms 8252 KB Output is partially correct - 179690 call(s) of encode_bit()
22 Correct 115 ms 8316 KB Output is partially correct - 222810 call(s) of encode_bit()
23 Correct 173 ms 9724 KB Output is partially correct - 266290 call(s) of encode_bit()
# 결과 실행 시간 메모리 Grader output
1 Correct 404 ms 14080 KB Output is partially correct - 351280 call(s) of encode_bit()
2 Correct 3 ms 4588 KB Output is correct - 120 call(s) of encode_bit()
3 Correct 27 ms 5336 KB Output is correct - 43840 call(s) of encode_bit()
4 Correct 3 ms 4600 KB Output is correct - 140 call(s) of encode_bit()
5 Correct 51 ms 6304 KB Output is partially correct - 104350 call(s) of encode_bit()
6 Correct 56 ms 6304 KB Output is partially correct - 106590 call(s) of encode_bit()
7 Correct 102 ms 8080 KB Output is partially correct - 217960 call(s) of encode_bit()
8 Correct 24 ms 5052 KB Output is correct - 28210 call(s) of encode_bit()
9 Correct 27 ms 5204 KB Output is correct - 30000 call(s) of encode_bit()
10 Correct 25 ms 5216 KB Output is correct - 29160 call(s) of encode_bit()
11 Correct 39 ms 5612 KB Output is correct - 55970 call(s) of encode_bit()
12 Correct 20 ms 4960 KB Output is correct - 19990 call(s) of encode_bit()
13 Correct 93 ms 7960 KB Output is partially correct - 183310 call(s) of encode_bit()
14 Correct 26 ms 5224 KB Output is correct - 32990 call(s) of encode_bit()
15 Correct 32 ms 5332 KB Output is correct - 33910 call(s) of encode_bit()
16 Correct 71 ms 6024 KB Output is correct - 62280 call(s) of encode_bit()
17 Correct 59 ms 6028 KB Output is correct - 67330 call(s) of encode_bit()
18 Correct 94 ms 7012 KB Output is partially correct - 119960 call(s) of encode_bit()
19 Correct 67 ms 6712 KB Output is partially correct - 124650 call(s) of encode_bit()
20 Correct 112 ms 8228 KB Output is partially correct - 182580 call(s) of encode_bit()
21 Correct 112 ms 8252 KB Output is partially correct - 179690 call(s) of encode_bit()
22 Correct 115 ms 8316 KB Output is partially correct - 222810 call(s) of encode_bit()
23 Correct 173 ms 9724 KB Output is partially correct - 266290 call(s) of encode_bit()
# 결과 실행 시간 메모리 Grader output
1 Correct 404 ms 14080 KB Output is partially correct - 351280 call(s) of encode_bit()
2 Correct 3 ms 4588 KB Output is correct - 120 call(s) of encode_bit()
3 Correct 27 ms 5336 KB Output is correct - 43840 call(s) of encode_bit()
4 Correct 3 ms 4600 KB Output is correct - 140 call(s) of encode_bit()
5 Correct 51 ms 6304 KB Output is partially correct - 104350 call(s) of encode_bit()
6 Correct 56 ms 6304 KB Output is partially correct - 106590 call(s) of encode_bit()
7 Correct 102 ms 8080 KB Output is partially correct - 217960 call(s) of encode_bit()
8 Correct 24 ms 5052 KB Output is correct - 28210 call(s) of encode_bit()
9 Correct 27 ms 5204 KB Output is correct - 30000 call(s) of encode_bit()
10 Correct 25 ms 5216 KB Output is correct - 29160 call(s) of encode_bit()
11 Correct 39 ms 5612 KB Output is correct - 55970 call(s) of encode_bit()
12 Correct 20 ms 4960 KB Output is correct - 19990 call(s) of encode_bit()
13 Correct 93 ms 7960 KB Output is partially correct - 183310 call(s) of encode_bit()
14 Correct 26 ms 5224 KB Output is correct - 32990 call(s) of encode_bit()
15 Correct 32 ms 5332 KB Output is correct - 33910 call(s) of encode_bit()
16 Correct 71 ms 6024 KB Output is correct - 62280 call(s) of encode_bit()
17 Correct 59 ms 6028 KB Output is correct - 67330 call(s) of encode_bit()
18 Correct 94 ms 7012 KB Output is partially correct - 119960 call(s) of encode_bit()
19 Correct 67 ms 6712 KB Output is partially correct - 124650 call(s) of encode_bit()
20 Correct 112 ms 8228 KB Output is partially correct - 182580 call(s) of encode_bit()
21 Correct 112 ms 8252 KB Output is partially correct - 179690 call(s) of encode_bit()
22 Correct 115 ms 8316 KB Output is partially correct - 222810 call(s) of encode_bit()
23 Correct 173 ms 9724 KB Output is partially correct - 266290 call(s) of encode_bit()