func_code_string: #include <bits/stdc++.h>   using namespace std;   int parent[300005], maxLen[300005];   int findRoot(int u) {     int root = u;     while (parent[root] != root) {       root = parent[root];     }     while (parent[u] != root) {       int y = parent[u];       parent[u] = root;       u = y;     }     return root;   }   void unionNum(int u, int v) {     int ru = findRoot(u), rv = findRoot(v);     if (ru == rv) return;     if (maxLen[ru] > maxLen[rv]) {       parent[rv] = ru;       maxLen[ru] = max(maxLen[ru], maxLen[ru] / 2 + maxLen[rv] / 2 +                                        maxLen[ru] % 2 + maxLen[rv] % 2 + 1);     } else {       swap(ru, rv);       parent[rv] = ru;       maxLen[ru] = max(maxLen[ru], maxLen[ru] / 2 + maxLen[rv] / 2 +                                        maxLen[ru] % 2 + maxLen[rv] % 2 + 1);     }   }   int visited[300005] = {0};   bool nVis(int &i, int n) {     while (i <= n && visited[i] == 1) i++;     if (i <= n) return true;     return false;   }   void dfs(int node, vector<int> child[]) {     map<int, int> v1, v2, d1, d2;     stack<int> myStack;     myStack.push(node);     v1[node] = 1;     d1[node] = 0;     visited[node] = 1;     while (!myStack.empty()) {       int y = myStack.top();       myStack.pop();       for (size_t i = 0; i < child[y].size(); i++) {         if (v1[child[y][i]] == 0) {           v1[child[y][i]] = 1;           d1[child[y][i]] = d1[y] + 1;           myStack.push(child[y][i]);           visited[child[y][i]] = 1;         }       }     }     for (map<int, int>::iterator it = d1.begin(); it != d1.end(); it++) {       if (d1[node] < it->second) {         node = it->first;       }     }     myStack.push(node);     d2[node] = 0;     v2[node] = 1;     while (!myStack.empty()) {       int y = myStack.top();       myStack.pop();       parent[y] = node;       for (size_t i = 0; i < child[y].size(); i++) {         if (v2[child[y][i]] == 0) {           v2[child[y][i]] = 1;           d2[child[y][i]] = d2[y] + 1;           maxLen[node] = max(maxLen[node], d2[child[y][i]]);           myStack.push(child[y][i]);         }       }     }   }   int main() {     int n, m, q, a, b;     scanf( %d%d%d , &n, &m, &q);     for (int i = 0; i <= n; i++) {       parent[i] = i;       maxLen[i] = 0;     }     vector<int> child[n + 1];     for (int i = 0; i < m; i++) {       scanf( %d%d , &a, &b);       child[a].push_back(b);       child[b].push_back(a);     }     int i = 1;     while (nVis(i, n)) {       dfs(i, child);     }     while (q--) {       int type;       scanf( %d , &type);       if (type == 1) {         scanf( %d , &a);         printf( %d n , maxLen[findRoot(a)]);       } else {         scanf( %d%d , &a, &b);         unionNum(a, b);       }     }   }   