Submission #564991

# Submission time Handle Problem Language Result Execution time Memory
564991 2022-05-20T07:01:53 Z shrimb Saveit (IOI10_saveit) C++17
25 / 100
252 ms 15624 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] = INT_MAX;
        dist[i] = 0;
        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[cur] + 1) {
                    dist[j] = dist[cur] + 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 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]);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 252 ms 15624 KB Output is partially correct - 354610 call(s) of encode_bit()
2 Correct 2 ms 4472 KB Output is correct - 150 call(s) of encode_bit()
3 Correct 26 ms 5532 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 48 ms 6628 KB Output is partially correct - 183850 call(s) of encode_bit()
6 Correct 58 ms 6524 KB Output is partially correct - 188290 call(s) of encode_bit()
7 Correct 90 ms 8756 KB Output is partially correct - 362010 call(s) of encode_bit()
8 Correct 17 ms 5096 KB Output is correct - 36530 call(s) of encode_bit()
9 Correct 22 ms 5264 KB Output is correct - 41030 call(s) of encode_bit()
10 Correct 23 ms 5132 KB Output is correct - 38950 call(s) of encode_bit()
11 Correct 36 ms 5848 KB Output is partially correct - 94710 call(s) of encode_bit()
12 Correct 16 ms 4996 KB Output is correct - 19990 call(s) of encode_bit()
13 Correct 77 ms 7856 KB Output is partially correct - 241570 call(s) of encode_bit()
14 Correct 19 ms 5288 KB Output is correct - 45450 call(s) of encode_bit()
15 Correct 22 ms 5336 KB Output is correct - 48550 call(s) of encode_bit()
16 Correct 52 ms 6500 KB Output is partially correct - 107030 call(s) of encode_bit()
17 Correct 51 ms 6372 KB Output is partially correct - 99230 call(s) of encode_bit()
18 Correct 66 ms 7408 KB Output is partially correct - 162330 call(s) of encode_bit()
19 Correct 51 ms 6712 KB Output is partially correct - 170990 call(s) of encode_bit()
20 Correct 83 ms 8392 KB Output is partially correct - 209830 call(s) of encode_bit()
21 Correct 96 ms 8600 KB Output is partially correct - 222830 call(s) of encode_bit()
22 Correct 97 ms 8720 KB Output is partially correct - 337210 call(s) of encode_bit()
23 Correct 115 ms 9740 KB Output is partially correct - 311990 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 252 ms 15624 KB Output is partially correct - 354610 call(s) of encode_bit()
2 Correct 2 ms 4472 KB Output is correct - 150 call(s) of encode_bit()
3 Correct 26 ms 5532 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 48 ms 6628 KB Output is partially correct - 183850 call(s) of encode_bit()
6 Correct 58 ms 6524 KB Output is partially correct - 188290 call(s) of encode_bit()
7 Correct 90 ms 8756 KB Output is partially correct - 362010 call(s) of encode_bit()
8 Correct 17 ms 5096 KB Output is correct - 36530 call(s) of encode_bit()
9 Correct 22 ms 5264 KB Output is correct - 41030 call(s) of encode_bit()
10 Correct 23 ms 5132 KB Output is correct - 38950 call(s) of encode_bit()
11 Correct 36 ms 5848 KB Output is partially correct - 94710 call(s) of encode_bit()
12 Correct 16 ms 4996 KB Output is correct - 19990 call(s) of encode_bit()
13 Correct 77 ms 7856 KB Output is partially correct - 241570 call(s) of encode_bit()
14 Correct 19 ms 5288 KB Output is correct - 45450 call(s) of encode_bit()
15 Correct 22 ms 5336 KB Output is correct - 48550 call(s) of encode_bit()
16 Correct 52 ms 6500 KB Output is partially correct - 107030 call(s) of encode_bit()
17 Correct 51 ms 6372 KB Output is partially correct - 99230 call(s) of encode_bit()
18 Correct 66 ms 7408 KB Output is partially correct - 162330 call(s) of encode_bit()
19 Correct 51 ms 6712 KB Output is partially correct - 170990 call(s) of encode_bit()
20 Correct 83 ms 8392 KB Output is partially correct - 209830 call(s) of encode_bit()
21 Correct 96 ms 8600 KB Output is partially correct - 222830 call(s) of encode_bit()
22 Correct 97 ms 8720 KB Output is partially correct - 337210 call(s) of encode_bit()
23 Correct 115 ms 9740 KB Output is partially correct - 311990 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 252 ms 15624 KB Output is partially correct - 354610 call(s) of encode_bit()
2 Correct 2 ms 4472 KB Output is correct - 150 call(s) of encode_bit()
3 Correct 26 ms 5532 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 48 ms 6628 KB Output is partially correct - 183850 call(s) of encode_bit()
6 Correct 58 ms 6524 KB Output is partially correct - 188290 call(s) of encode_bit()
7 Correct 90 ms 8756 KB Output is partially correct - 362010 call(s) of encode_bit()
8 Correct 17 ms 5096 KB Output is correct - 36530 call(s) of encode_bit()
9 Correct 22 ms 5264 KB Output is correct - 41030 call(s) of encode_bit()
10 Correct 23 ms 5132 KB Output is correct - 38950 call(s) of encode_bit()
11 Correct 36 ms 5848 KB Output is partially correct - 94710 call(s) of encode_bit()
12 Correct 16 ms 4996 KB Output is correct - 19990 call(s) of encode_bit()
13 Correct 77 ms 7856 KB Output is partially correct - 241570 call(s) of encode_bit()
14 Correct 19 ms 5288 KB Output is correct - 45450 call(s) of encode_bit()
15 Correct 22 ms 5336 KB Output is correct - 48550 call(s) of encode_bit()
16 Correct 52 ms 6500 KB Output is partially correct - 107030 call(s) of encode_bit()
17 Correct 51 ms 6372 KB Output is partially correct - 99230 call(s) of encode_bit()
18 Correct 66 ms 7408 KB Output is partially correct - 162330 call(s) of encode_bit()
19 Correct 51 ms 6712 KB Output is partially correct - 170990 call(s) of encode_bit()
20 Correct 83 ms 8392 KB Output is partially correct - 209830 call(s) of encode_bit()
21 Correct 96 ms 8600 KB Output is partially correct - 222830 call(s) of encode_bit()
22 Correct 97 ms 8720 KB Output is partially correct - 337210 call(s) of encode_bit()
23 Correct 115 ms 9740 KB Output is partially correct - 311990 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 252 ms 15624 KB Output is partially correct - 354610 call(s) of encode_bit()
2 Correct 2 ms 4472 KB Output is correct - 150 call(s) of encode_bit()
3 Correct 26 ms 5532 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 48 ms 6628 KB Output is partially correct - 183850 call(s) of encode_bit()
6 Correct 58 ms 6524 KB Output is partially correct - 188290 call(s) of encode_bit()
7 Correct 90 ms 8756 KB Output is partially correct - 362010 call(s) of encode_bit()
8 Correct 17 ms 5096 KB Output is correct - 36530 call(s) of encode_bit()
9 Correct 22 ms 5264 KB Output is correct - 41030 call(s) of encode_bit()
10 Correct 23 ms 5132 KB Output is correct - 38950 call(s) of encode_bit()
11 Correct 36 ms 5848 KB Output is partially correct - 94710 call(s) of encode_bit()
12 Correct 16 ms 4996 KB Output is correct - 19990 call(s) of encode_bit()
13 Correct 77 ms 7856 KB Output is partially correct - 241570 call(s) of encode_bit()
14 Correct 19 ms 5288 KB Output is correct - 45450 call(s) of encode_bit()
15 Correct 22 ms 5336 KB Output is correct - 48550 call(s) of encode_bit()
16 Correct 52 ms 6500 KB Output is partially correct - 107030 call(s) of encode_bit()
17 Correct 51 ms 6372 KB Output is partially correct - 99230 call(s) of encode_bit()
18 Correct 66 ms 7408 KB Output is partially correct - 162330 call(s) of encode_bit()
19 Correct 51 ms 6712 KB Output is partially correct - 170990 call(s) of encode_bit()
20 Correct 83 ms 8392 KB Output is partially correct - 209830 call(s) of encode_bit()
21 Correct 96 ms 8600 KB Output is partially correct - 222830 call(s) of encode_bit()
22 Correct 97 ms 8720 KB Output is partially correct - 337210 call(s) of encode_bit()
23 Correct 115 ms 9740 KB Output is partially correct - 311990 call(s) of encode_bit()