水题。
#include <cstdio>
#include <queue>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
const int maxn = 111;
int n,m;
vector<int> Node[maxn];
int hashtable[maxn] = {0};
//struct node{
// int data;
// vector<int> child;
//}Node[maxn];
void dfs(int index, int depth){
hashtable[depth] += 1;
if(Node[index].size() == 0)
return;
else{
for(int i=0;i<Node[index].size();i++){
dfs(Node[index][i], depth+1);
}
}
}
int main(){
int i,j,k,tmp;
scanf("%d %d", &n,&m);
for(i=0;i<m;i++){
scanf("%d %d", &j, &k);
for(int z=0;z<k;z++){
scanf("%d",&tmp);
Node[j].push_back(tmp);
}
}
dfs(1,1);
int mmax = -1;
int pos;
for(i=1;i<=maxn;i++)
if(hashtable[i]>mmax){
mmax = hashtable[i];
pos = i;
}
printf("%d %d",mmax,pos);
return 0;
}