Submission #565089

# Submission time Handle Problem Language Result Execution time Memory
565089 2022-05-20T08:55:42 Z AbdullahMW Saveit (IOI10_saveit) C++14
50 / 100
340 ms 12556 KB
#include <bits/stdc++.h>
#include "grader.h"
#include "encoder.h"

#define newl "\n"
#define ll int
#define pb push_back
#define f first
#define s second

using namespace std;


vector <ll> gr[1005];
vector <pair <ll, ll>> bfs(ll xx)
{
    vector <pair <ll, ll>> ret;
    queue <ll> q;
    unordered_map <ll, bool> vis;
    unordered_map <ll, ll> dist;
    
    q.push(xx);
    ret.pb({xx, 0});
    vis[xx] = true;
    while (q.size())
    {
        ll x = q.front();
        q.pop();
        
        for (auto v : gr[x])
        {
            if (!vis[v])
            {
                
                q.push(v);
                vis[v] = true;
                dist[v] = dist[x] + 1;
                ret.pb({v, dist[v]});
                
            }
        }
    }
    
    return ret;
}

void encode(ll n, ll h, ll p, ll a[], ll b[])
{
    for (ll i = 0; i < 1000; i++)
    {
        if (gr[i].size()) gr[i].clear();
    }
    
    for (ll i = 0; i < p; i++)
    {
        gr[a[i]].pb(b[i]);
        gr[b[i]].pb(a[i]);
    }
    
    for (ll i = 0; i < h; i++)
    {
        vector <pair <ll, ll>> vec = bfs(i);
        sort(vec.begin(), vec.end());
        //cout << "HUB: " << i << "  ";
        for (auto v : vec)
        {
            //cout << "City: " << v.f;
            //cout << " Dist: ";
            //cout << v.s;
            for (ll bit = 0; bit < 10; bit++)
            {
                bool b = (1 << bit) & v.s;
                //cout << bit;
                encode_bit(b);
            }
            //cout << " ";
        }
        //cout << newl;
    }
}

/*int main()
{
    ll a[] = {0, 0, 0, 0, 1, 1, 1};
    ll b[] = {1, 2, 3, 4, 2, 3, 4};
    ll n = 5, h = 3, p = 7;
    encode(n, h, p, a, b);
}*/

    
#include <bits/stdc++.h>
#include "grader.h"
#include "encoder.h"
#define ll int
#define pb push_back
#define f first
#define s second

using namespace std;


void decode(ll n, ll h)
{
    for (ll i = 0; i < h; i++)
    {
        for (ll j = 0; j < n; j++)
        {
            ll d = 0;
            for (ll bit = 0; bit < 10; bit++)
            {
                bool b = decode_bit();
                if (b) d += (1 << bit);
            }
            hops(i, j, d);
        }
    }
}


    
# Verdict Execution time Memory Grader output
1 Correct 340 ms 12556 KB Output is partially correct - 360000 call(s) of encode_bit()
2 Correct 3 ms 4604 KB Output is correct - 150 call(s) of encode_bit()
3 Correct 84 ms 7376 KB Output is partially correct - 324000 call(s) of encode_bit()
4 Correct 3 ms 4600 KB Output is correct - 250 call(s) of encode_bit()
5 Correct 82 ms 7444 KB Output is partially correct - 324000 call(s) of encode_bit()
6 Correct 83 ms 7824 KB Output is partially correct - 360000 call(s) of encode_bit()
7 Correct 112 ms 8176 KB Output is partially correct - 360000 call(s) of encode_bit()
8 Correct 82 ms 7364 KB Output is partially correct - 345960 call(s) of encode_bit()
9 Correct 93 ms 7656 KB Output is partially correct - 360000 call(s) of encode_bit()
10 Correct 89 ms 7692 KB Output is partially correct - 360000 call(s) of encode_bit()
11 Correct 92 ms 7788 KB Output is partially correct - 360000 call(s) of encode_bit()
12 Correct 80 ms 7748 KB Output is partially correct - 360000 call(s) of encode_bit()
13 Correct 121 ms 8304 KB Output is partially correct - 360000 call(s) of encode_bit()
14 Correct 100 ms 7600 KB Output is partially correct - 360000 call(s) of encode_bit()
15 Correct 96 ms 7664 KB Output is partially correct - 360000 call(s) of encode_bit()
16 Correct 116 ms 8188 KB Output is partially correct - 360000 call(s) of encode_bit()
17 Correct 103 ms 8060 KB Output is partially correct - 360000 call(s) of encode_bit()
18 Correct 134 ms 8476 KB Output is partially correct - 360000 call(s) of encode_bit()
19 Correct 96 ms 8008 KB Output is partially correct - 360000 call(s) of encode_bit()
20 Correct 125 ms 8636 KB Output is partially correct - 360000 call(s) of encode_bit()
21 Correct 147 ms 8832 KB Output is partially correct - 360000 call(s) of encode_bit()
22 Correct 107 ms 8328 KB Output is partially correct - 360000 call(s) of encode_bit()
23 Correct 159 ms 9000 KB Output is partially correct - 360000 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 340 ms 12556 KB Output is partially correct - 360000 call(s) of encode_bit()
2 Correct 3 ms 4604 KB Output is correct - 150 call(s) of encode_bit()
3 Correct 84 ms 7376 KB Output is partially correct - 324000 call(s) of encode_bit()
4 Correct 3 ms 4600 KB Output is correct - 250 call(s) of encode_bit()
5 Correct 82 ms 7444 KB Output is partially correct - 324000 call(s) of encode_bit()
6 Correct 83 ms 7824 KB Output is partially correct - 360000 call(s) of encode_bit()
7 Correct 112 ms 8176 KB Output is partially correct - 360000 call(s) of encode_bit()
8 Correct 82 ms 7364 KB Output is partially correct - 345960 call(s) of encode_bit()
9 Correct 93 ms 7656 KB Output is partially correct - 360000 call(s) of encode_bit()
10 Correct 89 ms 7692 KB Output is partially correct - 360000 call(s) of encode_bit()
11 Correct 92 ms 7788 KB Output is partially correct - 360000 call(s) of encode_bit()
12 Correct 80 ms 7748 KB Output is partially correct - 360000 call(s) of encode_bit()
13 Correct 121 ms 8304 KB Output is partially correct - 360000 call(s) of encode_bit()
14 Correct 100 ms 7600 KB Output is partially correct - 360000 call(s) of encode_bit()
15 Correct 96 ms 7664 KB Output is partially correct - 360000 call(s) of encode_bit()
16 Correct 116 ms 8188 KB Output is partially correct - 360000 call(s) of encode_bit()
17 Correct 103 ms 8060 KB Output is partially correct - 360000 call(s) of encode_bit()
18 Correct 134 ms 8476 KB Output is partially correct - 360000 call(s) of encode_bit()
19 Correct 96 ms 8008 KB Output is partially correct - 360000 call(s) of encode_bit()
20 Correct 125 ms 8636 KB Output is partially correct - 360000 call(s) of encode_bit()
21 Correct 147 ms 8832 KB Output is partially correct - 360000 call(s) of encode_bit()
22 Correct 107 ms 8328 KB Output is partially correct - 360000 call(s) of encode_bit()
23 Correct 159 ms 9000 KB Output is partially correct - 360000 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 340 ms 12556 KB Output is partially correct - 360000 call(s) of encode_bit()
2 Correct 3 ms 4604 KB Output is correct - 150 call(s) of encode_bit()
3 Correct 84 ms 7376 KB Output is partially correct - 324000 call(s) of encode_bit()
4 Correct 3 ms 4600 KB Output is correct - 250 call(s) of encode_bit()
5 Correct 82 ms 7444 KB Output is partially correct - 324000 call(s) of encode_bit()
6 Correct 83 ms 7824 KB Output is partially correct - 360000 call(s) of encode_bit()
7 Correct 112 ms 8176 KB Output is partially correct - 360000 call(s) of encode_bit()
8 Correct 82 ms 7364 KB Output is partially correct - 345960 call(s) of encode_bit()
9 Correct 93 ms 7656 KB Output is partially correct - 360000 call(s) of encode_bit()
10 Correct 89 ms 7692 KB Output is partially correct - 360000 call(s) of encode_bit()
11 Correct 92 ms 7788 KB Output is partially correct - 360000 call(s) of encode_bit()
12 Correct 80 ms 7748 KB Output is partially correct - 360000 call(s) of encode_bit()
13 Correct 121 ms 8304 KB Output is partially correct - 360000 call(s) of encode_bit()
14 Correct 100 ms 7600 KB Output is partially correct - 360000 call(s) of encode_bit()
15 Correct 96 ms 7664 KB Output is partially correct - 360000 call(s) of encode_bit()
16 Correct 116 ms 8188 KB Output is partially correct - 360000 call(s) of encode_bit()
17 Correct 103 ms 8060 KB Output is partially correct - 360000 call(s) of encode_bit()
18 Correct 134 ms 8476 KB Output is partially correct - 360000 call(s) of encode_bit()
19 Correct 96 ms 8008 KB Output is partially correct - 360000 call(s) of encode_bit()
20 Correct 125 ms 8636 KB Output is partially correct - 360000 call(s) of encode_bit()
21 Correct 147 ms 8832 KB Output is partially correct - 360000 call(s) of encode_bit()
22 Correct 107 ms 8328 KB Output is partially correct - 360000 call(s) of encode_bit()
23 Correct 159 ms 9000 KB Output is partially correct - 360000 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 340 ms 12556 KB Output is partially correct - 360000 call(s) of encode_bit()
2 Correct 3 ms 4604 KB Output is correct - 150 call(s) of encode_bit()
3 Correct 84 ms 7376 KB Output is partially correct - 324000 call(s) of encode_bit()
4 Correct 3 ms 4600 KB Output is correct - 250 call(s) of encode_bit()
5 Correct 82 ms 7444 KB Output is partially correct - 324000 call(s) of encode_bit()
6 Correct 83 ms 7824 KB Output is partially correct - 360000 call(s) of encode_bit()
7 Correct 112 ms 8176 KB Output is partially correct - 360000 call(s) of encode_bit()
8 Correct 82 ms 7364 KB Output is partially correct - 345960 call(s) of encode_bit()
9 Correct 93 ms 7656 KB Output is partially correct - 360000 call(s) of encode_bit()
10 Correct 89 ms 7692 KB Output is partially correct - 360000 call(s) of encode_bit()
11 Correct 92 ms 7788 KB Output is partially correct - 360000 call(s) of encode_bit()
12 Correct 80 ms 7748 KB Output is partially correct - 360000 call(s) of encode_bit()
13 Correct 121 ms 8304 KB Output is partially correct - 360000 call(s) of encode_bit()
14 Correct 100 ms 7600 KB Output is partially correct - 360000 call(s) of encode_bit()
15 Correct 96 ms 7664 KB Output is partially correct - 360000 call(s) of encode_bit()
16 Correct 116 ms 8188 KB Output is partially correct - 360000 call(s) of encode_bit()
17 Correct 103 ms 8060 KB Output is partially correct - 360000 call(s) of encode_bit()
18 Correct 134 ms 8476 KB Output is partially correct - 360000 call(s) of encode_bit()
19 Correct 96 ms 8008 KB Output is partially correct - 360000 call(s) of encode_bit()
20 Correct 125 ms 8636 KB Output is partially correct - 360000 call(s) of encode_bit()
21 Correct 147 ms 8832 KB Output is partially correct - 360000 call(s) of encode_bit()
22 Correct 107 ms 8328 KB Output is partially correct - 360000 call(s) of encode_bit()
23 Correct 159 ms 9000 KB Output is partially correct - 360000 call(s) of encode_bit()