#include<stdio.h>
#include<vector>
using namespace std;
struct pnode{
vector<int> child;
}node[110];
int depth_num[110]={0}, max_num=-1, level;
void DFS(int root, int depth){
depth_num[depth]++;
if(depth_num[depth]>max_num){max_num=depth_num[depth]; level=depth;}
for(int i=0;i<node[root].child.size();i++){
DFS(node[root].child[i],depth+1);
}
}
int main(){
int i, j, k, n, m, id, temp;
scanf("%d%d",&n,&m);
for(i=0;i<m;i++){
scanf("%d%d",&id,&k);
for(j=0;j<k;j++){
scanf("%d",&temp);
node[id].child.push_back(temp);
}
}
DFS(1,1);
printf("%d %d\n",max_num,level);
return 0;
}
PAT-A1094
最新推荐文章于 2022-01-18 11:52:44 发布