func_code_string: #include <bits/stdc++.h>   using namespace std;   struct Point {     int num;     int next[3001];     int count;   };   Point a[3001];   int dis[3001];   int p[3001];   int cir[3001];   int cir1[3001];   int f(int n) {     int i, num = 0, d = 1;   loop:     while (1) {       num = 0;       for (i = 1; i <= n; i++) {         if (a[i].num - a[i].count == 1) {           a[i].count++;           p[num++] = i;         }       }       for (i = 0; i < num; i++) {         for (int j = 0; j < a[p[i]].num; j++) a[a[p[i]].next[j]].count++;       }       for (i = 1; i <= n; i++) {         if (a[i].num - a[i].count > 0 && a[i].num - a[i].count != 2) goto loop;       }       num = 0;       for (i = 1; i <= n; i++) {         if (a[i].num - a[i].count == 2) cir[num++] = i;       }       return num;     }   }   int main() {     int b[4], n, i, t, sum, num, flag;     int from, to;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> from >> to;       a[from].next[a[from].num++] = to;       a[to].next[a[to].num++] = from;     }     int step = 0;     sum = num = f(n);     memset(dis, 0xff, sizeof(dis));     for (i = 0; i < num; i++) dis[cir[i]] = step;     while (sum < n) {       int k = 0;       step++;       flag = 0;       for (i = 0; i < num; i++) {         for (int j = 0; j < a[cir[i]].num; j++) {           int next = a[cir[i]].next[j];           if (dis[next] == -1) {             sum++;             flag = 1;             dis[next] = step;             cir1[k++] = next;             continue;           }         }         if (!flag) cir[i] = -1;       }       memcpy(cir, cir1, k * sizeof(cir1[0]));       num = k;     }     for (i = 1; i <= n; i++)       if (i != n)         cout << dis[i] <<    ;       else         cout << dis[i] << endl;     return 0;   }   