func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<int> E[3010];   int mark[3010];   int c, f;   bool find(int i, int p) {     if (mark[i] == 1) {       c = i;       f = 1;       return true;     }     mark[i] = 1;     for (vector<int>::iterator to = E[i].begin(); to < E[i].end(); to++) {       if (*to != p && find(*to, i)) {         if (f) mark[i] = 2;         if (i == c) f = 0;         return true;       }     }     return false;   }   int ans[3010];   void bfs(int i) {     queue<int> v;     v.push(i);     while (!v.empty()) {       int to = v.front();       v.pop();       for (vector<int>::iterator at = E[to].begin(); at < E[to].end(); at++) {         if (ans[*at] > ans[to] + 1) {           ans[*at] = ans[to] + 1;           v.push(*at);         }       }     }   }   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       int a, b;       scanf( %d%d , &a, &b);       a--;       b--;       E[a].push_back(b);       E[b].push_back(a);     }     find(0, -1);     for (int i = 0; i < 3010; i++) ans[i] = 10000000;     for (int i = 0; i < n; i++)       if (mark[i] == 2) {         ans[i] = 0;         bfs(i);       }     for (int i = 0; i < n; i++) printf( %d  , ans[i]);     return 0;   }   