Submission #394915

# Submission time Handle Problem Language Result Execution time Memory
394915 2021-04-27T13:39:59 Z MarcoMeijer Saveit (IOI10_saveit) C++14
0 / 100
500 ms 35216 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);
    return mx;
}

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

    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;
                q.push(v);
            }
        }
        
        vi prev = {h};
        RE1(i,nv) {
            vi cur;
            RE(u,nv) if(dist[u] == i) cur.pb(u);
            FOR(u,cur) {
                bool found = false;
                FOR(v,prev) if(usedEdges.count({min(u,v),max(u,v)})) {
                    found = true;
                    break;
                }
                if(!found) FOR(v,prev) if(difEdges.count({u,v})) {
                    usedEdges.insert({min(u,v),max(u,v)});
                    break;
                }
            }
            if(cur.empty()) break;
            prev = cur;
        }
    }

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

    RE(i,nv) {
        writeSmallInt(adj[i].size(), 10);
        FOR(v,adj[i]) writeSmallInt(v, maxBits(i-1));
    }
}
#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 maxBits(int x) {
    int mx = 0;
    RE(i,10) if(x&(1<<i)) mx = max(mx, i);
    return mx;
}

void decode(int nv, int nh) {
    // reconstruct graph
    vector<vi> adj; adj.resize(nv);
    RE(u,nv) {
        int sz = readSmallInt(10);
        RE(j,sz) {
            int v = readSmallInt(maxBits(u-1));
            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);
            }
        }
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 500 ms 35216 KB Output isn't correct
2 Incorrect 4 ms 4584 KB Output isn't correct
3 Incorrect 148 ms 5624 KB function hops(h,c,d) must be called exactly N×H times
4 Incorrect 3 ms 4584 KB Output isn't correct
5 Incorrect 144 ms 6736 KB Output isn't correct
6 Incorrect 184 ms 6944 KB Output isn't correct
7 Incorrect 204 ms 9864 KB Output isn't correct
8 Incorrect 46 ms 5068 KB function hops(h,c,d) must be called exactly N×H times
9 Incorrect 49 ms 5328 KB function hops(h,c,d) must be called exactly N×H times
10 Incorrect 48 ms 5264 KB function hops(h,c,d) must be called exactly N×H times
11 Incorrect 63 ms 6332 KB function hops(h,c,d) must be called exactly N×H times
12 Incorrect 108 ms 4960 KB function hops(h,c,d) must be called exactly N×H times
13 Incorrect 164 ms 9876 KB function hops(h,c,d) must be called exactly N×H times
14 Incorrect 90 ms 5444 KB function hops(h,c,d) must be called exactly N×H times
15 Incorrect 87 ms 5760 KB function hops(h,c,d) must be called exactly N×H times
16 Incorrect 153 ms 9096 KB function hops(h,c,d) must be called exactly N×H times
17 Incorrect 120 ms 8456 KB function hops(h,c,d) must be called exactly N×H times
18 Incorrect 146 ms 9852 KB function hops(h,c,d) must be called exactly N×H times
19 Incorrect 120 ms 7688 KB function hops(h,c,d) must be called exactly N×H times
20 Incorrect 184 ms 11396 KB function hops(h,c,d) must be called exactly N×H times
21 Incorrect 193 ms 12636 KB function hops(h,c,d) must be called exactly N×H times
22 Incorrect 206 ms 10248 KB function hops(h,c,d) must be called exactly N×H times
23 Incorrect 222 ms 13668 KB function hops(h,c,d) must be called exactly N×H times
# Verdict Execution time Memory Grader output
1 Incorrect 500 ms 35216 KB Output isn't correct
2 Incorrect 4 ms 4584 KB Output isn't correct
3 Incorrect 148 ms 5624 KB function hops(h,c,d) must be called exactly N×H times
4 Incorrect 3 ms 4584 KB Output isn't correct
5 Incorrect 144 ms 6736 KB Output isn't correct
6 Incorrect 184 ms 6944 KB Output isn't correct
7 Incorrect 204 ms 9864 KB Output isn't correct
8 Incorrect 46 ms 5068 KB function hops(h,c,d) must be called exactly N×H times
9 Incorrect 49 ms 5328 KB function hops(h,c,d) must be called exactly N×H times
10 Incorrect 48 ms 5264 KB function hops(h,c,d) must be called exactly N×H times
11 Incorrect 63 ms 6332 KB function hops(h,c,d) must be called exactly N×H times
12 Incorrect 108 ms 4960 KB function hops(h,c,d) must be called exactly N×H times
13 Incorrect 164 ms 9876 KB function hops(h,c,d) must be called exactly N×H times
14 Incorrect 90 ms 5444 KB function hops(h,c,d) must be called exactly N×H times
15 Incorrect 87 ms 5760 KB function hops(h,c,d) must be called exactly N×H times
16 Incorrect 153 ms 9096 KB function hops(h,c,d) must be called exactly N×H times
17 Incorrect 120 ms 8456 KB function hops(h,c,d) must be called exactly N×H times
18 Incorrect 146 ms 9852 KB function hops(h,c,d) must be called exactly N×H times
19 Incorrect 120 ms 7688 KB function hops(h,c,d) must be called exactly N×H times
20 Incorrect 184 ms 11396 KB function hops(h,c,d) must be called exactly N×H times
21 Incorrect 193 ms 12636 KB function hops(h,c,d) must be called exactly N×H times
22 Incorrect 206 ms 10248 KB function hops(h,c,d) must be called exactly N×H times
23 Incorrect 222 ms 13668 KB function hops(h,c,d) must be called exactly N×H times
# Verdict Execution time Memory Grader output
1 Incorrect 500 ms 35216 KB Output isn't correct
2 Incorrect 4 ms 4584 KB Output isn't correct
3 Incorrect 148 ms 5624 KB function hops(h,c,d) must be called exactly N×H times
4 Incorrect 3 ms 4584 KB Output isn't correct
5 Incorrect 144 ms 6736 KB Output isn't correct
6 Incorrect 184 ms 6944 KB Output isn't correct
7 Incorrect 204 ms 9864 KB Output isn't correct
8 Incorrect 46 ms 5068 KB function hops(h,c,d) must be called exactly N×H times
9 Incorrect 49 ms 5328 KB function hops(h,c,d) must be called exactly N×H times
10 Incorrect 48 ms 5264 KB function hops(h,c,d) must be called exactly N×H times
11 Incorrect 63 ms 6332 KB function hops(h,c,d) must be called exactly N×H times
12 Incorrect 108 ms 4960 KB function hops(h,c,d) must be called exactly N×H times
13 Incorrect 164 ms 9876 KB function hops(h,c,d) must be called exactly N×H times
14 Incorrect 90 ms 5444 KB function hops(h,c,d) must be called exactly N×H times
15 Incorrect 87 ms 5760 KB function hops(h,c,d) must be called exactly N×H times
16 Incorrect 153 ms 9096 KB function hops(h,c,d) must be called exactly N×H times
17 Incorrect 120 ms 8456 KB function hops(h,c,d) must be called exactly N×H times
18 Incorrect 146 ms 9852 KB function hops(h,c,d) must be called exactly N×H times
19 Incorrect 120 ms 7688 KB function hops(h,c,d) must be called exactly N×H times
20 Incorrect 184 ms 11396 KB function hops(h,c,d) must be called exactly N×H times
21 Incorrect 193 ms 12636 KB function hops(h,c,d) must be called exactly N×H times
22 Incorrect 206 ms 10248 KB function hops(h,c,d) must be called exactly N×H times
23 Incorrect 222 ms 13668 KB function hops(h,c,d) must be called exactly N×H times
# Verdict Execution time Memory Grader output
1 Incorrect 500 ms 35216 KB Output isn't correct
2 Incorrect 4 ms 4584 KB Output isn't correct
3 Incorrect 148 ms 5624 KB function hops(h,c,d) must be called exactly N×H times
4 Incorrect 3 ms 4584 KB Output isn't correct
5 Incorrect 144 ms 6736 KB Output isn't correct
6 Incorrect 184 ms 6944 KB Output isn't correct
7 Incorrect 204 ms 9864 KB Output isn't correct
8 Incorrect 46 ms 5068 KB function hops(h,c,d) must be called exactly N×H times
9 Incorrect 49 ms 5328 KB function hops(h,c,d) must be called exactly N×H times
10 Incorrect 48 ms 5264 KB function hops(h,c,d) must be called exactly N×H times
11 Incorrect 63 ms 6332 KB function hops(h,c,d) must be called exactly N×H times
12 Incorrect 108 ms 4960 KB function hops(h,c,d) must be called exactly N×H times
13 Incorrect 164 ms 9876 KB function hops(h,c,d) must be called exactly N×H times
14 Incorrect 90 ms 5444 KB function hops(h,c,d) must be called exactly N×H times
15 Incorrect 87 ms 5760 KB function hops(h,c,d) must be called exactly N×H times
16 Incorrect 153 ms 9096 KB function hops(h,c,d) must be called exactly N×H times
17 Incorrect 120 ms 8456 KB function hops(h,c,d) must be called exactly N×H times
18 Incorrect 146 ms 9852 KB function hops(h,c,d) must be called exactly N×H times
19 Incorrect 120 ms 7688 KB function hops(h,c,d) must be called exactly N×H times
20 Incorrect 184 ms 11396 KB function hops(h,c,d) must be called exactly N×H times
21 Incorrect 193 ms 12636 KB function hops(h,c,d) must be called exactly N×H times
22 Incorrect 206 ms 10248 KB function hops(h,c,d) must be called exactly N×H times
23 Incorrect 222 ms 13668 KB function hops(h,c,d) must be called exactly N×H times