func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<int> graph[3123];   vector<vector<int> > vCiclos;   int dist[3123];   int vis[3123];   vector<int> v;   int ciclo[3123];   int tamanhoCiclo[3123];   int cnt = 1;   int n;   bool cycle[3123];   void dfs(int x, int pai) {     vis[x] = 1;     v.push_back(x);     for (int i = 0; i < graph[x].size(); ++i) {       int y = graph[x][i];       if (y == pai) continue;       if (vis[y] == 0) {         dfs(y, x);       } else if (vis[y] == 1) {         vector<int> aux;         for (int j = v.size() - 1;; --j) {           int vert = v[j];           ciclo[vert] = cnt;           aux.push_back(v[j]);           cycle[v[j]] = true;           if (vert == y) break;         }         cnt++;         vCiclos.push_back(aux);       }     }     vis[x] = 2;     v.pop_back();   }   void dfs2(int x, int pai, int k) {     dist[x] = k;     for (int i = 0; i < graph[x].size(); i++) {       int y = graph[x][i];       if (y == pai || cycle[y]) continue;       dfs2(y, x, k + 1);     }   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       int x, y;       scanf( %d %d , &x, &y);       graph[x].push_back(y);       graph[y].push_back(x);     }     dfs(1, 1);     for (int i = 0; i < vCiclos.size(); i++) {       for (int j = 0; j < vCiclos[i].size(); j++) {         int y = vCiclos[i][j];         dfs2(y, y, 0);       }     }     for (int i = 1; i <= n; i++) printf( %d  , dist[i]);     cout << endl;     return 0;   }   