题目 A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population. Input Specification: Each input file contains one test…
题目如下: #include<iostream> #include<vector> #include<algorithm> using namespace std; int book[100]; vector<int> vi[100]; void dfs(int index, int level){ book[level]++;//第一层肯定是有的,即根节点 for(int i = 0; i < vi[index].size(); i++){ dfs(…
题目很简单,就是统计一下每层的节点数,输出节点数最多的个数和对应的层数即可. #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> using namespace std; ; int num[maxn]; int head[maxn]; int tot; struct Edge{ int to; int next; }edge[maxn]; void i…
本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/93311728 1094 The Largest Generation (25 分)   A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task…
PTA甲级1094 The Largest Generation (25分) A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population. Input Specificatio…
http://www.patest.cn/contests/pat-a-practise/1094 A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population. Input S…
简单DFS. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<map> #include<queue> #include<stack> #include<vector> using namespace std; ; int n,m; vector<int>g[maxn]; int ans[…
题意: 输入两个正整数N和M(N<100,M<N),表示结点数量和有孩子结点的结点数量,输出拥有结点最多的层的结点数量和层号(根节点为01,层数为1,层号向下递增). AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; vector<]; ]; void dfs(int x,int storey){ ++ans[storey]; for(aut…
A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population. Input Specification: Each input file contains one test ca…
https://pintia.cn/problem-sets/994805342720868352/problems/994805372601090048 A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the…