func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<vector<int>> adj, CC;   const int MX = 1e5 + 69;   int n, m, q, vis[MX], dis[MX], pa[MX], compsz[MX], D[MX];   int parent(int x) {     if (x == pa[x]) return x;     return pa[x] = parent(pa[x]);   }   bool cmp(int a, int b) {     if (dis[a] != dis[b]) return dis[a] < dis[b];     return a < b;   }   long long* cum[MX];   int* compel[MX];   int bfs(int x, bool ok) {     int p = parent(x);     queue<int> q;     q.push(x);     vis[x] = 0;     vector<int> v;     while (!q.empty()) {       int nxt = q.front();       v.push_back(nxt);       q.pop();       for (auto u : adj[nxt]) {         if (vis[u] == -1) {           vis[u] = vis[nxt] + 1;           dis[u] = max(dis[u], vis[u]);           q.push(u);           D[p] = max(D[p], dis[u]);         }       }     }     int mx = -69, opt = x;     while (!v.empty() && ok == 1) {       int nxt = v.back();       v.pop_back();       if (mx < vis[nxt]) {         mx = vis[nxt];         opt = nxt;       }       vis[nxt] = -1;     }     if (ok) return opt;     sort(v.begin(), v.end(), cmp);     int sz = v.size(), j = 0;     long long sum = 0;     p = parent(x);     compel[p] = new int[D[p] + 2];     cum[p] = new long long[D[p] + 2];     for (int i = 0; i <= D[p] + 1; i++) cum[p][i] = compel[p][i] = 0;     for (auto u : v) {       j++;       sum += dis[u];       cum[p][dis[u] + 1] = sum;       compel[p][dis[u] + 1] = j;     }     compsz[p] = v.size();     CC[p] = v;     v.clear();     return opt;   }   long double nig[MX];   void join(int u, int v) {     u = parent(u);     v = parent(v);     if (u == v) return;     pa[u] = v;   }   map<int, long double> quer[MX];   int DD;   long double solve(int u, int v) {     if (compsz[u] > compsz[v]) swap(u, v);     if (quer[u].count(v)) return quer[u][v];     DD = max(D[u], D[v]);     long double ret = 0;     for (int i = 0; i < compsz[u]; i++) {       int nxt = CC[u][i];       int l = min(D[v], max(-1, DD - dis[nxt] - 2));       long double r = compsz[v] - compel[v][l + 1];       ret += r * (dis[nxt] + 1) + cum[v][D[v] + 1] - cum[v][l + 1] +              (long double)compel[v][l + 1] * DD;     }     return quer[u][v] = ret / ((long double)compsz[u] * compsz[v]);   }   int main() {     cin >> n >> m >> q;     for (int i = 1; i <= n; i++) pa[i] = i;     memset(vis, -1, sizeof vis);     adj.resize(n + 69);     CC.resize(n + 69);     for (int i = 1; i <= m; i++) {       int u, v;       scanf( %d%d , &u, &v);       adj[u].push_back(v);       adj[v].push_back(u);       join(u, v);     }     for (int i = 1; i <= n; i++) {       if (i != parent(i)) continue;       int p = parent(i);       int u = bfs(i, 1);       u = bfs(u, 1);       bfs(u, 0);     }     cout << fixed;     cout.precision(10);     for (int i = 1; i <= q; i++) {       int u, v;       scanf( %d%d , &u, &v);       u = parent(u);       v = parent(v);       if (u == v)         cout << -1 << endl;       else         cout << solve(u, v) << endl;     }     return 0;   }   