Submission #601088

#TimeUsernameProblemLanguageResultExecution timeMemory
601088l_rehoSaveit (IOI10_saveit)C++14
50 / 100
300 ms16356 KiB
#include "grader.h" #include "encoder.h" #include <bits/stdc++.h> using namespace std; vector<vector<int>> dist; vector<vector<int>> graph; struct info{ int d; int node; bool operator< (const info& rhs) const { return d > rhs.d; } }; void solver(int hub){ queue<info> q; q.push({0, hub}); dist[hub][hub] = 0; while(!q.empty()){ info i = q.front(); q.pop(); int node = i.node; int d = i.d; vector<int> adj = graph[node]; for(int a : adj){ if(dist[hub][a] != INT_MAX) continue; dist[hub][a] = d+1; q.push({d+1, a}); } } } void encode(int nv, int nh, int ne, int *v1, int *v2){ // per ogni hub calcolo la distanza da ogni altro hub dist.assign(nv, vector<int>(nv, INT_MAX)); graph.assign(nv, vector<int>()); for(int i = 0; i < ne; i++){ graph[v1[i]].push_back(v2[i]); graph[v2[i]].push_back(v1[i]); } for(int i = 0; i < nh; i++) solver(i); // adesso gli invio le informazioni for(int h = 0; h < nh; h++){ for(int v = 0; v < nv; v++){ // faccio l'encode di dist[h][v] string bts = ""; while(dist[h][v]){ // 11 bit char c = (dist[h][v] & 1) + '0'; bts = c + bts; dist[h][v] >>= 1; } bts = string(10-bts.length(), '0') + bts; // cout<<"DEBUG-->"<<bts.length()<<endl; for(char c : bts) encode_bit(c-'0'); } } return; }
#include "grader.h" #include "decoder.h" #include <bits/stdc++.h> using namespace std; void decode(int nv, int nh) { /* int a = decode_bit(); int b = decode_bit(); hops(0,0,0); hops(1,2,3); * */ for(int h = 0; h < nh; h++){ for(int v = 0; v < nv; v++){ int d = 0; for(int i = 9; i >= 0; i--){ int b = decode_bit(); // cout<<"DEBUG-->"<<h<<" "<<v<<" "<<b<<endl; if(b) d += (1<<i); } hops(h, v, d); // decodifico e invio } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...