# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
201969 | 2020-02-12T23:02:53 Z | Leonardo_Paes | Saveit (IOI10_saveit) | C++17 | 0 ms | 0 KB |
#include "encoder.h" #include "grader.h" #include "vector" #include "queue" using namespace std; vector <int> grafo[1100]; int dist[1100][1100]; void encode(int n, int h, int p, int *v1, int *v2){ for(int i=0; i<n; i++) grafo[i].clear(); for(int i=0; i<h; i++){ grafo[v1[i]].push_back(v2[i]); grafo[v2[i]].push_back(v1[i]); } for(int i=0; i<h; i++){ for(int j=0; j<n; j++){ dist[i][j] = 0x3f3f3f3f; } queue<int> q; q.push(i); dist[i][i] = 0; while(!q.empty()){ int u = q.front(); q.pop(); for(auto v : grafo[u]){ if (dist[i][u] + 1 < dist[i][v]){ dist[i][v] = dist[i][u] + 1; q.push(v); } } } } for(int i=0; i<h; i++){ for(int j=0; j<n; j++){ for(int k=0; k<10; k++){ encode_bit(((dist[i][j]&(1<<k))&1)); } } } }