1094. The Largest Generation (25)(bfs)

kettle连接达梦资源库数据库插件 kettle自定义插件plugin database plugin 达梦插件 dm插件 阅读详情

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 the generation with the largest population.

Input Specification:

Each input file contains one test case. Each case starts with two positive integers N (<100) which is the total number of family members in the tree (and hence assume that all the members are numbered from 01 to N), and M (<N) which is the number of family members who have children. Then M lines follow, each contains the information of a family member in the following format:

ID K ID[1] ID[2] ... ID[K]

where ID is a two-digit number representing a family member, K (>0) is the number of his/her children, followed by a sequence of two-digit ID's of his/her children. For the sake of simplicity, let us fix the root ID to be 01. All the numbers in a line are separated by a space.

Output Specification:

For each test case, print in one line the largest population number and the level of the corresponding generation. It is assumed that such a generation is unique, and the root level is defined to be 1.

Sample Input:
23 13
21 1 23
01 4 03 02 04 05
03 3 06 07 08
06 2 12 13
13 1 21
08 2 15 16
02 2 09 10
11 2 19 20
17 1 22
05 1 11
07 1 14
09 1 17
10 1 18
Sample Output:
9 4
bfs层序遍历

code:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
int n,m;
vector<int>G[110];
int vis[110];
struct node{
    int level;
    int id;
}s,nexts;
struct generation{
    int num;
    int level;
}g[110];
void bfs(){
    queue<node>q;
    vis[1] = 1;
    s.level = 1;
    s.id = 1;
    g[1].num = 1;
    q.push(s);
    while(!q.empty()){
        s = q.front();
        q.pop();
        for(int i = 0; i < G[s.id].size(); i++){
            if(!vis[G[s.id][i]]){
                vis[G[s.id][i]] = 1;
                nexts.id = G[s.id][i];
                nexts.level = s.level + 1;
                g[nexts.level].num++;
                q.push(nexts);
            }
        }
    }
}
bool cmp(generation a,generation b){
    return a.num > b.num;
}
int main(){
    int i,j;
    for(i = 0; i < 110; i++){
        g[i].level = i;
        g[i].num = 0;
    }
    cin >> n >> m;
    for(i = 0; i < m; i++){
        int id,k,son;
        cin >> id >> k;
        for(j = 0; j < k; j++){
            cin >> son;
            G[id].push_back(son);
        }
    }
    memset(vis,0,sizeof(vis));
    bfs();
    sort(g+1,g+1+n,cmp);
    cout << g[1].num << " " << g[1].level << endl;
    return 0;
}

BEV和OCC学习-4:数据准备生成pkl文件(NuSences) info[‘cam_instances’][‘CAM_XXX’][i][‘bbox_3d’]:长度为 7 的列表,以 (x, y, z, l, h, w, yaw) 的顺序表示实例的 3D 边界框。info[‘cam_instances’][‘CAM_XXX’][i][‘bbox’]:2D 边界框标注(3D 框投影的矩形框),顺序为 [x1, y1, x2, y2] 的列表。info[‘cam_instances’][‘CAM_XXX’][i][‘attr_label’]:实例的属性标签。 阅读详情

相关推荐

Robot Arm 机械臂源码解析

由于我们用的是步进电机,运动的时候是一步一步的,并不是平滑的,这里假设在一个平面上面,一个x步进电机,一个y步进电机。那么放大它们所走的轨迹就会是阶梯状的。而它们也只能沿着网格运动。相当于有了一个最小的分辨率,这个分辨率就是一步。如下图所示,如果x,y电机同时走就能走出45度的斜线。在三维空间里面运动也是如此,你应该可以想象的出来;首先,是updateActualPosition,用来时时更新此时的差补位置,得到的是一个路径与时间t的函数(其中路径的范围为0,1,时间范围为0,dist/v)...

爱吃炸鸡的小猪's blog 1万+

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: Each input file contains one test case. Ea

weixin_45962741的博客 563

Spring Boot 实现多图片上传并回显,涨姿势了~

上传 Controller的代码非常简单,由于用了SpringMVC框架,所以直接用MultipartFile来接即可。由于是多图片上传所以用数组来接。此处应该注意参数名应该和<input>中的name值相对应: @RequestMapping("/pic") @ResponseBody publicResponseEntity<String>pic(MultipartFile[]pictures)throwsException{ ResponseEnti...

weixin_54556126的博客 893

1094. The Largest Generation (25) 此题和六度空间一个道理,记录BFS的层次

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

qwesde 1546

ArcMap实战:用栅格计算器搞定16年NDVI趋势分析,附完整F检验流程

本文详细介绍了如何使用ArcMap的栅格计算器进行16年NDVI趋势分析,包括数据预处理、线性趋势计算和F显著性检验的全流程操作。通过实际案例和统计原理解析,帮助GIS从业者掌握植被覆盖变化的分析方法,特别适合生态评估和农业监测应用。

weixin_29251567的博客 252

小红书图文AI创作:输入主题,一键生成图文(coze工作流教程+获取)

输入主题,工作流一键生成小红书风格图文,30s一条,可批量生成

2301_79384090的博客 2798

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...

qq_43813697的博客 273

OpenClaw 技术架构解析-网关层(上)

OpenClaw 网关层是架构核心中枢,承接Channel层消息,串联消息路由器、会话状态管理器等五大组件,负责消息分发、会话管理、状态统筹、上下文维护等关键职责,是连接Channel层与AI执行引擎的核心桥梁,保障多渠道交互稳定、有序运行。

wend的博客 710

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 S

hg_zhh 466

uniapp(vue3):实现手机拍照或相册图片上传后给图片添加水印,uniapp实现多端图片上传、拍照上传自定义插入水印内容,调用手机摄像头打开相机并在周围悬挂自定义水印(支持文字水印/图片水印等)

uni-app,h5移动端网页,微信小程序,支付宝小程序,Android安卓,苹果ios,app,nvue,uni-app为图片添加自定义水印(解决生成图片不全问题),uniapp上传图片添加水印,uniapp H5实现手机拍照或相册上传图像并添加自定义水印,uniapp水印相机,uni-app为图片添加自定义水印,怎么在图片上加水印,图片水印,上传照片带水印,从相册选择图片加水印功能,拍完照片给图片加水印,添加照片水印,uniapp图片加水印,为图片添加自定义水印,uni-app上传图片并添加水印,上传图

✅ 精选推荐文章 3263

scratch绘制旋转彩球 2023年9月电子学会图形化编程scratch编程等级考试四级真题和答案解析

​ scratch绘制旋转彩球 2023年9月电子学会图形化编程Scratch等级考试四级真题 一、题目要求 1、准备工作 (1)删除小猫角色,从角色库选择Ball角色; (2)默认空白背景。 ​

青少年编程学习指导 1365

PAT甲级--1094 The Largest Generation(25 分)【DFS+BFS+输出一层最多的结点数】

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 w...

Imagirl1的博客 283

(八)DDR_PHY架构及功能——(PUB组成、初始化及Training流程、Clock关系)

文章目录一、DDR_PHY结构组成1.1、DDR Memory子系统1.2、DDR_PHY架构组成1.3、PUB模块功能实现流程1.3.1、DDR系统初始化流程1.3.2、PLL初始化流程 一、DDR_PHY结构组成 1.1、DDR Memory子系统   Memory子系统主要由DDR Controller和DDR_PHY(含DDR_IO)两个部分组成。DDR Controller主要承担其它子系统(如CPU)与Memory子系统进行数据交互时的传输效率及调度,DDR_PHY主要负责数据交互过程中的传输速

Mr.翟的博客 1万+

1094 The Largest Generation (25 分)(BFS)

#include <cstdio> #include <vector> #include<queue> #include<algorithm> using namespace std; struct node { int layer; vector<int>child; }Node[110]; int n,m,level ...

Tog 199

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

甲级PAT 1094 The Largest Generation (25 分)(bfs)

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 ...

Joyceyang_999的博客 212

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

PAT——1094 The Largest Generation (25 分)(BFS遍历树)

1094The 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 ...

a429367172的博客 235

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

pat甲级 1094 The Largest Generation (25 分)(dfs或者bfs)

题目链接: 传送门 思路:直接dfs或者bfs记录每层的节点数即可 代码: dfs: #include <bits/stdc++.h> using namespace std; const int maxn = 105; vector <int> g[maxn]; int h[maxn]; int mm; void dfs(int u , int d) { h[d...

一只谜谜怪的博客 284

1094 The Largest Generation (25 分)(树的遍历,BFS,DFS)

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 ...

qq_42068614的博客 210

PAT 1094. The Largest Generation (25)(bfs遍历)

官网 题目 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 node

hxshine的博客 362

【PAT甲级】1094 The Largest Generation(25 分)(dfs/bfs)

题目链接 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. ...

feng_zhiyu的博客 345

PAT (Advanced Level) Practice_1094 The Largest Generation (25分)(C++_N叉树_BFS)

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 case. Ea

ccql's Blog 298

PAT 甲级 1094 The Largest Generation (25分) DFS BFS

PAT 甲级 1094 The Largest Generation (25分) DFS BFS

星辰不问 160

BFS_1094 The Largest Generation

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 ...

A_Bo的博客 369

PAT A1094 The Largest Generation

PAT A1094 The Largest Generation Sample Input: 23 13 21 1 23 01 4 03 02 04 05 03 3 06 07 08 06 2 12 13 13 1 21 08 2 15 16 02 2 09 10 11 2 19 20 17 1 22 05 1 11 07 1 14 09 1 17 10 1 18 Sample Output:...

qq_42347617的博客 241

1094 The Largest Generation (25分)【BFS解法】

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 ...

ikunsaikou的博客 159

PAT 甲级 1094  The Largest Generation

1094 The Largest Generation (25 point(s)) 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 gene...

漫浸天空的雨色的备忘录~ 577
上一篇: 1091. Acute Stroke (30)(bfs)
下一篇: 1097. Deduplication on a Linked List (25)
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值