# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
476855 | 2021-09-28T18:42:12 Z | wiktoria_bazan | Saveit (IOI10_saveit) | C++14 | 0 ms | 0 KB |
#include "grader.h" #include "encoder.h" #include<vector> int const N = 1e3 + 9; int const H = 40; int d[H][N]; bool odw[H][N]; vector<int> G[N]; void dfs(int v, int in, int w) { odw[in][v] = true; d[in][v] = w; for (int i = 0; i < G[v].size(); i++) { int sas = G[v][i]; if (!odw[in][sas]) dfs(sas, in, w + 1); } } void int_to_bits(int a) { //9 bitów int pot = 1 << 9; while (a > 0) { if (a > pot) { encode_bit(1); a -= pot; } else encode_bit(0); pot >>= 1; } } void encode(int nv, int nh, int ne, int* v1, int* v2) { for (int i = 0; i < ne; i++) { G[v1[i]].push_back(G[v2[i]]); G[v2[i]].push_back(G[v1[i]]); } for (int h = 0; h < nh; h++) { dfs(h, h, 0); for (int v = 0; v < nv; v++) { int_to_bits(d[h][v]); } } return; }