标签:const mes 技术总结 printf 相等 bit pre clu using
#include<bits/stdc++.h>;
using namespace std;
const int maxn = 110;
struct node{
vector<int> child;
}Node[maxn];
int hashTable[maxn] = {0};
int max_h = -1;
void DFS(int root, int depth){
if(Node[root].child.size() == 0){
hashTable[depth]++;
max_h = max(depth, max_h);
return;
}
for(int i = 0; i < Node[root].child.size(); i++){
DFS(Node[root].child[i], depth+1);
}
}
int main(){
int n, num;
scanf("%d", &n);
if(n == 0) return 0;
scanf("%d", &num);
int id, sum;
for(int i = 0; i < num; i++){
scanf("%d%d", &id, &sum);
int id2;
for(int j = 0; j < sum; j++){
scanf("%d", &id2);
Node[id].child.push_back(id2);
}
}
DFS(1, 0);
for(int i = 0; i <= max_h; i++){
if(i != 0) printf(" ");
printf("%d", hashTable[i]);
}
return 0;
}
标签:const mes 技术总结 printf 相等 bit pre clu using
原文地址:https://www.cnblogs.com/tsruixi/p/12324267.html