提交时间:2023-08-23 16:14:57
运行 ID: 99715
#include <iostream> using namespace std; #define int long long struct{ int f,c1,c2,d; }a[1005]; //bool a[i][j] 表示i和j是否联通 signed main(){ int n; cin >> n; a[1].d=1; int maxn = 0; for (int i = 1;i<=n;i++){ int x,y; cin >> x >> y; //if (x==y&&x==0) continue; a[i].c1=x,a[i].c2=y; a[x].f=a[y].f=i; a[x].d=a[y].d=a[i].d+1; maxn = max(maxn,a[i].d+1); } cout << maxn; }