func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 10;   vector<int> G[maxn];   int p[maxn], d[maxn], vis[maxn], mx, rt;   int find(int x) {     if (p[x] != x) p[x] = find(p[x]);     return p[x];   }   void dfs(int u, int fa, int dep, int tp) {     vis[u] = 1;     if (dep > mx) {       mx = dep;       if (!tp) rt = u;     }     if (tp) p[u] = rt;     for (int i = 0; i < G[u].size(); i++) {       int v = G[u][i];       if (v != fa) dfs(v, u, dep + 1, tp);     }   }   int main() {     int n, m, q, tp, u, v;     scanf( %d%d%d , &n, &m, &q);     for (int i = 1; i <= n; i++) p[i] = i;     for (int i = 1; i <= m; i++) {       scanf( %d%d , &u, &v);       G[u].push_back(v);       G[v].push_back(u);     }     for (int i = 1; i <= n; i++)       if (!vis[i]) {         mx = rt = 0;         dfs(i, 0, 0, 0);         dfs(rt, 0, 0, 1);         d[rt] = mx;       }     while (q--) {       scanf( %d , &tp);       if (tp == 2) {         scanf( %d%d , &u, &v);         int fu = find(u), fv = find(v);         if (fu != fv) {           p[fu] = fv;           int t1 = d[fu] / 2 + d[fu] % 2;           int t2 = d[fv] / 2 + d[fv] % 2;           d[fv] = max(d[fu], d[fv]);           d[fv] = max(d[fv], t1 + t2 + 1);         }       } else {         scanf( %d , &u);         int fu = find(u);         printf( %d n , d[fu]);       }     }   }   