题目 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(…
本文同步发布在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…
题目很简单,就是统计一下每层的节点数,输出节点数最多的个数和对应的层数即可. #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…
1094. The Largest Generation (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue 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…
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 Specification: Ea…
1094 The Largest Generation 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 inp…
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…
求结点最多的一层 输出该层的结点个数以及层号 #include<bits/stdc++.h> using namespace std; vector<]; map<int,int>mp; void dfs(int v,int step) { mp[step]++; ){ return; } ;i<vec[v].size();i++){ dfs(vec[v][i],step+); } } int main() { int n,m; scanf("%d %d&qu…
#include<bits/stdc++.h>using namespace std;int n,m,l,t;int a[1307][137][67];int vis[1307][137][67];typedef struct{    int x,y,z;}node;int xx[6]={0,0,0,0,1,-1};int yy[6]={0,0,1,-1,0,0};int zz[6]={1,-1,0,0,0,0};node p;int bfs(int x,int y,int z){    qu…
CODE: #include<cstdio> #include<cstring> #include<queue> using namespace std; bool mat[105][105]; bool root[105]; int n,m; int R; int cnt[105]; int ans1,ans2; struct TNode { int num; int level; }; void BFS() { queue<TNode> Q; TNode…
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…
题意:略. 思路:层序遍历:在结点中增加一个数据域表示结点所在的层次. 代码: #include <cstdio> #include <queue> #include <vector> using namespace std; struct Node{ int layer; vector<int> child; }; vector<Node> tree(); ]={}; ,maxNum=; void levelOrderTraversal(int…
1094. The Largest Generation (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue 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…
Source: PAT A1094 The Largest Generation (25 分) Description: 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 populati…
PAT乙级:1090危险品装箱(25分) 题干 集装箱运输货物时,我们必须特别小心,不能把不相容的货物装在一只箱子里.比如氧化剂绝对不能跟易燃液体同箱,否则很容易造成爆炸. 本题给定一张不相容物品的清单,需要你检查每一张集装箱货品清单,判断它们是否能装在同一只箱子里. 输入格式: 输入第一行给出两个正整数:N (≤104) 是成对的不相容物品的对数:M (≤100) 是集装箱货品清单的单数. 随后数据分两大块给出.第一块有 N 行,每行给出一对不相容的物品.第二块有 M 行,每行给出一箱货物的清…
PAT乙级:1070 结绳 (25分) 题干 给定一段一段的绳子,你需要把它们串成一条绳.每次串连的时候,是把两段绳子对折,再如下图所示套接在一起.这样得到的绳子又被当成是另一段绳子,可以再次对折去跟另一段绳子串连.每次串连后,原来两段绳子的长度就会减半. 给定 N 段绳子的长度,你需要找出它们能串成的绳子的最大长度. 输入格式: 每个输入包含 1 个测试用例.每个测试用例第 1 行给出正整数 N (2≤N≤104):第 2 行给出 N 个正整数,即原始绳段的长度,数字间以空格分隔.所有整数都不…
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…
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…
1007. Maximum Subsequence Sum (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to be { Ni, Ni+1, ..., Nj} where 1 <= i <= j <= K. The …
1010. 一元多项式求导 (25) 设计函数求一元多项式的导数.(注:xn(n为整数)的一阶导数为n*xn-1.) 输入格式:以指数递降方式输入多项式非零项系数和指数(绝对值均为不超过1000的整数).数字间以空格分隔. 输出格式:以与输入相同的格式输出导数多项式非零项的系数和指数.数字间以空格分隔,但结尾不能有多余空格.注意“零多项式”的指数和系数都是0,但是表示为“0 0”. 输入样例: 3 4 -5 2 6 1 -2 0 输出样例: 12 3 -10 1 6 0 程序说明: 1.使用 v…
1007 Maximum Subsequence Sum (25)(25 分) Given a sequence of K integers { N~1~, N~2~, ..., N~K~ }. A continuous subsequence is defined to be { N~i~, N~i+1~, ..., N~j~ } where 1 <= i <= j <= K. The Maximum Subsequence is the continuous subsequence…
1040 Longest Symmetric String (25 分)   Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, given Is PAT&TAP symmetric?, the longest symmetric sub-string is s PAT&TAP s, hence you must output 11.…
题意: 输入一个正整数N(<=101),接着输入N个学生的姓名,id和成绩.接着输入两个正整数X,Y(0<=X,Y<=100),逆序输出成绩在x,y之间的学生的姓名和id. trick: 测试点3格式错误因为输出的所有学生姓名和id后面都要换行,大概如果PAT没说不要输出多余的换行的话,就全都加个换行,说了就不加.....…