#include<cstdio>
#include<iostream>
#include<vector>
using namespace std;
const int maxn=101;
int p[maxn]={0},maxp=-1,maxdepth;
vector<int> node[maxn];
void DFS(int index,int depth)
{
p[depth]++;
if(p[depth]>maxp)
{
maxp=p[depth];
maxdepth=depth;
}
for(int i=0;i<node[index].size();i++)
{
DFS(node[index][i],depth+1);
}
}
int main()
{
int n,m,k,father,child;
cin>>n>>m;
for(int i=0;i<m;i++)
{
scanf("%d %d",&father,&k);
for(int j=0;j<k;j++)
{
scanf("%d",&child);
node[father].push_back(child);
}
}
DFS(1,1);
printf("%d %d",maxp,maxdepth);
}
A1094 The Largest Generation (25) 树的遍历
最新推荐文章于 2022-10-11 16:38:57 发布