답안 #564992

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
564992 2022-05-20T07:10:32 Z shrimb 저장 (Saveit) (IOI10_saveit) C++17
25 / 100
243 ms 15604 KB
#include "grader.h"
#include "encoder.h"
#include"bits/stdc++.h"
using namespace std;


void encode(int n, int h, int p, int *v1, int *v2){
    vector<pair<int,int>> adj[n + 1];
    for (int i = 0 ; i < p ; i++) {
        adj[v1[i]].emplace_back(v2[i],i);
        adj[v2[i]].emplace_back(v1[i],i);
    }
    vector<bool> ye(p);
    for (int i = 0 ; i < h ; i++) {
        int dist[n];
        for (int j = 0 ; j < n ; j++) dist[j] = 0;
        dist[i] = 1;
        queue<int> q;
        q.push(i);
        while (q.size()) {
            auto cur = q.front();
            q.pop();
            for (auto [j,k] : adj[cur]) {
                if (!dist[j]) {
                    dist[j] = 1;
                    ye[k] = 1;
                    q.push(j);
                }
            }
        }
    }
    for (int i = 0 ; i < p ; i++) {
        if (!ye[i]) continue;
        for (int k = 0 ; k < 10 ; k++) {
            encode_bit(bool(v1[i] & (1 << k)));
        }
        for (int k = 0 ; k < 10 ; k++) {
            encode_bit(bool(v2[i] & (1 << k)));
        }
    }
    for (int i = 0 ; i < 10 ; i++) encode_bit(1);
}
#include "grader.h"
#include "decoder.h"
#include "bits/stdc++.h"
using namespace std;
void decode(int n, int h) {

    auto getnum = [&]() -> int {
        int ret = 0;
        for (int k = 0 ; k < 10 ; k++) {
            ret |= (1 << k) * decode_bit();
        }
        return ret;
    };

    vector<int> adj[n];

    while (true) {
        int a = getnum();
        if (__builtin_popcount(a) == 10) break;
        int b = getnum();
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    for (int i = 0 ; i < h ; i++) {
        int dist[n];
        for (int j = 0 ; j < n ; j++) dist[j] = INT_MAX;
        queue<int> q;
        q.push(i);
        dist[i] = 0;
        while (q.size()) {
            auto cur = q.front();
            q.pop();
            for (int j : adj[cur]) {
                if (dist[j] > dist[cur] + 1) {
                    dist[j] = dist[cur] + 1;
                    q.push(j);
                }
            }
        }
        for (int j = 0 ; j < n ; j++) hops(i, j, dist[j]);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 243 ms 15604 KB Output is partially correct - 354610 call(s) of encode_bit()
2 Correct 3 ms 4476 KB Output is correct - 150 call(s) of encode_bit()
3 Correct 24 ms 5436 KB Output is correct - 69690 call(s) of encode_bit()
4 Correct 3 ms 4604 KB Output is correct - 190 call(s) of encode_bit()
5 Correct 60 ms 6652 KB Output is partially correct - 183850 call(s) of encode_bit()
6 Correct 52 ms 6836 KB Output is partially correct - 188290 call(s) of encode_bit()
7 Correct 87 ms 8768 KB Output is partially correct - 362010 call(s) of encode_bit()
8 Correct 22 ms 5044 KB Output is correct - 36530 call(s) of encode_bit()
9 Correct 28 ms 5220 KB Output is correct - 41030 call(s) of encode_bit()
10 Correct 22 ms 5292 KB Output is correct - 38950 call(s) of encode_bit()
11 Correct 35 ms 5956 KB Output is partially correct - 94710 call(s) of encode_bit()
12 Correct 15 ms 5016 KB Output is correct - 19990 call(s) of encode_bit()
13 Correct 86 ms 7816 KB Output is partially correct - 241570 call(s) of encode_bit()
14 Correct 20 ms 5244 KB Output is correct - 45450 call(s) of encode_bit()
15 Correct 20 ms 5364 KB Output is correct - 48550 call(s) of encode_bit()
16 Correct 48 ms 6540 KB Output is partially correct - 107030 call(s) of encode_bit()
17 Correct 59 ms 6420 KB Output is partially correct - 99230 call(s) of encode_bit()
18 Correct 67 ms 7316 KB Output is partially correct - 162330 call(s) of encode_bit()
19 Correct 52 ms 6924 KB Output is partially correct - 170990 call(s) of encode_bit()
20 Correct 80 ms 8320 KB Output is partially correct - 209830 call(s) of encode_bit()
21 Correct 87 ms 8476 KB Output is partially correct - 222830 call(s) of encode_bit()
22 Correct 108 ms 8760 KB Output is partially correct - 337210 call(s) of encode_bit()
23 Correct 112 ms 9636 KB Output is partially correct - 311990 call(s) of encode_bit()
# 결과 실행 시간 메모리 Grader output
1 Correct 243 ms 15604 KB Output is partially correct - 354610 call(s) of encode_bit()
2 Correct 3 ms 4476 KB Output is correct - 150 call(s) of encode_bit()
3 Correct 24 ms 5436 KB Output is correct - 69690 call(s) of encode_bit()
4 Correct 3 ms 4604 KB Output is correct - 190 call(s) of encode_bit()
5 Correct 60 ms 6652 KB Output is partially correct - 183850 call(s) of encode_bit()
6 Correct 52 ms 6836 KB Output is partially correct - 188290 call(s) of encode_bit()
7 Correct 87 ms 8768 KB Output is partially correct - 362010 call(s) of encode_bit()
8 Correct 22 ms 5044 KB Output is correct - 36530 call(s) of encode_bit()
9 Correct 28 ms 5220 KB Output is correct - 41030 call(s) of encode_bit()
10 Correct 22 ms 5292 KB Output is correct - 38950 call(s) of encode_bit()
11 Correct 35 ms 5956 KB Output is partially correct - 94710 call(s) of encode_bit()
12 Correct 15 ms 5016 KB Output is correct - 19990 call(s) of encode_bit()
13 Correct 86 ms 7816 KB Output is partially correct - 241570 call(s) of encode_bit()
14 Correct 20 ms 5244 KB Output is correct - 45450 call(s) of encode_bit()
15 Correct 20 ms 5364 KB Output is correct - 48550 call(s) of encode_bit()
16 Correct 48 ms 6540 KB Output is partially correct - 107030 call(s) of encode_bit()
17 Correct 59 ms 6420 KB Output is partially correct - 99230 call(s) of encode_bit()
18 Correct 67 ms 7316 KB Output is partially correct - 162330 call(s) of encode_bit()
19 Correct 52 ms 6924 KB Output is partially correct - 170990 call(s) of encode_bit()
20 Correct 80 ms 8320 KB Output is partially correct - 209830 call(s) of encode_bit()
21 Correct 87 ms 8476 KB Output is partially correct - 222830 call(s) of encode_bit()
22 Correct 108 ms 8760 KB Output is partially correct - 337210 call(s) of encode_bit()
23 Correct 112 ms 9636 KB Output is partially correct - 311990 call(s) of encode_bit()
# 결과 실행 시간 메모리 Grader output
1 Correct 243 ms 15604 KB Output is partially correct - 354610 call(s) of encode_bit()
2 Correct 3 ms 4476 KB Output is correct - 150 call(s) of encode_bit()
3 Correct 24 ms 5436 KB Output is correct - 69690 call(s) of encode_bit()
4 Correct 3 ms 4604 KB Output is correct - 190 call(s) of encode_bit()
5 Correct 60 ms 6652 KB Output is partially correct - 183850 call(s) of encode_bit()
6 Correct 52 ms 6836 KB Output is partially correct - 188290 call(s) of encode_bit()
7 Correct 87 ms 8768 KB Output is partially correct - 362010 call(s) of encode_bit()
8 Correct 22 ms 5044 KB Output is correct - 36530 call(s) of encode_bit()
9 Correct 28 ms 5220 KB Output is correct - 41030 call(s) of encode_bit()
10 Correct 22 ms 5292 KB Output is correct - 38950 call(s) of encode_bit()
11 Correct 35 ms 5956 KB Output is partially correct - 94710 call(s) of encode_bit()
12 Correct 15 ms 5016 KB Output is correct - 19990 call(s) of encode_bit()
13 Correct 86 ms 7816 KB Output is partially correct - 241570 call(s) of encode_bit()
14 Correct 20 ms 5244 KB Output is correct - 45450 call(s) of encode_bit()
15 Correct 20 ms 5364 KB Output is correct - 48550 call(s) of encode_bit()
16 Correct 48 ms 6540 KB Output is partially correct - 107030 call(s) of encode_bit()
17 Correct 59 ms 6420 KB Output is partially correct - 99230 call(s) of encode_bit()
18 Correct 67 ms 7316 KB Output is partially correct - 162330 call(s) of encode_bit()
19 Correct 52 ms 6924 KB Output is partially correct - 170990 call(s) of encode_bit()
20 Correct 80 ms 8320 KB Output is partially correct - 209830 call(s) of encode_bit()
21 Correct 87 ms 8476 KB Output is partially correct - 222830 call(s) of encode_bit()
22 Correct 108 ms 8760 KB Output is partially correct - 337210 call(s) of encode_bit()
23 Correct 112 ms 9636 KB Output is partially correct - 311990 call(s) of encode_bit()
# 결과 실행 시간 메모리 Grader output
1 Correct 243 ms 15604 KB Output is partially correct - 354610 call(s) of encode_bit()
2 Correct 3 ms 4476 KB Output is correct - 150 call(s) of encode_bit()
3 Correct 24 ms 5436 KB Output is correct - 69690 call(s) of encode_bit()
4 Correct 3 ms 4604 KB Output is correct - 190 call(s) of encode_bit()
5 Correct 60 ms 6652 KB Output is partially correct - 183850 call(s) of encode_bit()
6 Correct 52 ms 6836 KB Output is partially correct - 188290 call(s) of encode_bit()
7 Correct 87 ms 8768 KB Output is partially correct - 362010 call(s) of encode_bit()
8 Correct 22 ms 5044 KB Output is correct - 36530 call(s) of encode_bit()
9 Correct 28 ms 5220 KB Output is correct - 41030 call(s) of encode_bit()
10 Correct 22 ms 5292 KB Output is correct - 38950 call(s) of encode_bit()
11 Correct 35 ms 5956 KB Output is partially correct - 94710 call(s) of encode_bit()
12 Correct 15 ms 5016 KB Output is correct - 19990 call(s) of encode_bit()
13 Correct 86 ms 7816 KB Output is partially correct - 241570 call(s) of encode_bit()
14 Correct 20 ms 5244 KB Output is correct - 45450 call(s) of encode_bit()
15 Correct 20 ms 5364 KB Output is correct - 48550 call(s) of encode_bit()
16 Correct 48 ms 6540 KB Output is partially correct - 107030 call(s) of encode_bit()
17 Correct 59 ms 6420 KB Output is partially correct - 99230 call(s) of encode_bit()
18 Correct 67 ms 7316 KB Output is partially correct - 162330 call(s) of encode_bit()
19 Correct 52 ms 6924 KB Output is partially correct - 170990 call(s) of encode_bit()
20 Correct 80 ms 8320 KB Output is partially correct - 209830 call(s) of encode_bit()
21 Correct 87 ms 8476 KB Output is partially correct - 222830 call(s) of encode_bit()
22 Correct 108 ms 8760 KB Output is partially correct - 337210 call(s) of encode_bit()
23 Correct 112 ms 9636 KB Output is partially correct - 311990 call(s) of encode_bit()