1004 Counting Leaves (30 point(s))

4D毫米波雷达:高度信息与微多普勒效应 4D毫米波雷达:高度信息与微多普勒效应​ ,人工智能,计算机视觉,大模型,AI,本文深入解析4D毫米波雷达的高度信息获取与微多普勒效应。4D毫米波雷达通过MIMO技术、垂直天线布局及相位差计算等获取高度信息,相较传统雷达更精准。微多普勒效应由目标微运动引发,可用于目标识别、分类和运动监测。文中结合自动驾驶、安防监控案例,分析技术挑战与未来趋势,如信号干扰、数据处理复杂,未来将向高精度、与其他传感器融合发展,展现出在多领域的巨大应用潜力。 阅读详情

1004 Counting Leaves (30 point(s))

A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.

Input Specification:

Each input file contains one test case. Each case starts with a line containing 0<N<100, the number of nodes in a tree, and M (<N), the number of non-leaf nodes. Then M lines follow, each in the format:

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

where ID is a two-digit number representing a given non-leaf node, K is the number of its children, followed by a sequence of two-digit ID's of its children. For the sake of simplicity, let us fix the root ID to be 01.

The input ends with N being 0. That case must NOT be processed.

Output Specification:

For each test case, you are supposed to count those family members who have no child for every seniority levelstarting from the root. The numbers must be printed in a line, separated by a space, and there must be no extra space at the end of each line.

The sample case represents a tree with only 2 nodes, where 01 is the root and 02 is its only child. Hence on the root 01 level, there is 0 leaf node; and on the next level, there is 1 leaf node. Then we should output 0 1 in a line.

Sample Input:

2 1
01 1 02

Sample Output:

0 1

题意:计算一棵树的每一个层次的叶子节点。

思路:深度优先搜索(广度优先搜索也可以),注意标记每个结点所在的层次。直到该节点没有儿子节点结束,根据该节点的层次,cnt[]自增。

BFS参考大神链接:https://blog.youkuaiyun.com/richenyunqi/article/details/79533166

#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
const int MAX = 107;
vector<int> graph[MAX];
int level[MAX]={0};
int cnt[MAX]={0};
int maxLevel = 0;
void dfs(int v){
	if(graph[v].size()==0){
		cnt[level[v]]++;
		return;
	}
	for(int i=0;i<graph[v].size();i++){
		int cur = graph[v][i];
		level[cur]=level[v]+1;
		maxLevel = max(maxLevel,level[cur]);
		dfs(cur);
	}
}
int main(void){
	int N,M;cin>>N>>M;
	int id,k,a;
	while(M--){
		cin>>id>>k;
		while(k--){
			cin>>a;
			graph[id].push_back(a);
		}
	}
	int root = 1;
	dfs(root);
	for(int i=0;i<=maxLevel;i++){
		if(i==0) cout<<cnt[i];
		else cout<<" "<<cnt[i];
	}
	return 0;
} 

 

把 ST03 的历史数据留得更久:ABAP Workload 统计保留期设置、原理与落地避坑指南 SAP ST03性能数据保留期配置指南 ST03/ST03N是SAP系统性能分析的核心工具,但默认数据保留期通常较短(3个月左右),难以满足跨季度对比、年度规划等需求。本文详细解析了ST03数据保留期的配置方法及注意事项: 数据存储机制:性能数据存储在监控库中,通过定期重组作业清理过期数据 配置路径:7.0+系统在"Workload Collector Database→Reorganization→Control"中按Profile分别设置 关键限制:保留期最大值建议不超过99,否则可 阅读详情

相关推荐

MIPI video mode 和 command mode 的区别

1、何为LCD RAM? LCD 是指字面意思是液晶显示屏(Liquid Crystal Display), 而RAM: 随机存取存储器(Random-Access Memory),两者完全是风马牛不相及的东西。 下图是一个标准的LCD的爆炸图(不含TP),请注意图中红色mark的地方:控制IC-- LCD的大脑。所谓的LCD RAM自然是指此大脑是否包含RAM. 题外话<不感兴趣的...

精诚所至 4691

1004 Counting Leaves (30 point(s))

1004 Counting Leaves (30 point(s)) A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Input Specification: Each input file cont...

Willen_的博客 340

【扫地机器人】详细介绍扫地机器人软硬件测试和场景化测试

本文提出2025版扫地机器人全生命周期测试方案,涵盖实验室仿真、硬件台架、客户实景等全流程验证。测试以"清洁率≥95%、覆盖率≥98%、MTBF≥1000h"为核心指标,采用数字孪生与120套真实场景结合的双V模型。重点包括:传感器精度(LDS误差<±10mm)、清洁系统性能(10g粉尘吸入率≥99%)、动力续航(800次循环容量保持≥80%)等硬件测试;以及SLAM重定位(误差<5cm)、AI识别(mAP>92%)等软件验证。方案特别针对宠物家庭(毛发缠绕率≤3%)、

2501_92897788的博客 2288

[PAT-Advanced] A1004 Counting Leaves (30)

文章目录A1004 Counting Leaves (30point(s))Input Specification:Output Specification:Sample Input:Sample Output:CodeAnalysis A1004 Counting Leaves (30point(s)) A family hierarchy is usually presented by a p...

Duke 312

永磁同步电机矢量控制——电流内环前馈解耦策略

在采用永磁同步电机矢量控制时,ud和uq的指令值存在耦合项。需要对其进行解耦,目前,常用的解耦设计方法有前馈解耦、偏差解耦以及内模控制,本文主要分享电流内环前馈解耦控制策略。

a12312341ll的博客 8696

保姆级教程:用GATK4分析重测序数据,从fq.gz到vcf文件一步不落

本文提供了一份详细的GATK4重测序数据分析教程,涵盖从原始fq.gz文件到最终vcf文件的完整上游分析流程。通过Miniconda环境配置、数据质控、序列比对、变异检测等步骤的逐步指导,帮助生物信息学研究人员掌握标准流程,特别适合Linux命令行基础薄弱的研究者学习实践。

weixin_28366053的博客 486

PAT:1004 Counting Leaves (30分)(dfs遍历)

A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Input Specification: Each input file contains one test case. Each case starts with a line containing 0<N<100, the number of nodes

stackempty2的博客 243

使用 Python 获取网络数据

本文介绍了 Python 获取网络数据、使用 requests 库、编写爬虫代码以及使用 IP 代理的方法。Python 的 requests 库非常方便,可以帮助我们快速访问网络资源。编写爬虫程序需要掌握正则表达式、HTTP 协议等知识,同时需要注意爬取速度和频率,以避免对被爬取网站造成负担。最后,使用 IP 代理可以帮助我们隐匿身份,保护我们的网络安全。

互联说 2695

PAT甲级真题(并查集)——1004 Counting Leaves (30 分)

1004 Counting Leaves (30 分) A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Input Specification: Each input file contains one t...

WangXin Programmer 526

信奥赛C++提高组csp-s之数论基础专题课:从同余到分数模运算1(知识地图:同余、裴蜀定理、扩展欧几里得、乘法逆元、分数模运算)

信奥赛C++提高组csp-s之数论基础专题课:从同余到分数模运算1(知识地图:同余、裴蜀定理、扩展欧几里得、乘法逆元、分数模运算)

王老师青少年编程 791

matlab 点云均值、中值、高斯滤波【2024最新版】

点云均值滤波、中值滤波、高斯滤波的matlab自带函数实现。博客长期更新,本文最近一次更新时间为:2024年11月9日。

点云侠的博客 5259

1004 Counting Leaves (30point(s))

1004 Counting Leaves (30point(s)) A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Input Specification: Each input file contains one test case. Each case starts with a line containing

佳迪斯的博客 166

Codex 100个真实案例 - 用AI绘制CAD机械图纸(工程师看了直呼内行)

本案例将展示如何用 Codex 生成 Python 脚本,通过 `ezdxf` 库绘制标准 DXF 格式的 CAD 机械图纸。我们会从零开始,逐步实现直线、圆、圆弧、标注等基本图形元素,最终绘制出一张包含主视图、俯视图、尺寸标注、标题栏和技术要求的完整法兰盘零件图。还会演示参数化批量生成不同规格零件图和自动 BOM 物料清单,生成的 DXF 文件可直接在 AutoCAD、FreeCAD 中打开。全程用自然语言驱动 Codex,工程师看完直接上手!

yueyeguzhuo的专栏 2084

A1004 Counting Leaves (30point(s))

A1004 Counting Leaves (30point(s)) #include<cstdio> #include<algorithm> #include<vector> #include<queue> using namespace std; const int maxn = 101; int N, M; struct Node{ ve...

LEOSATA's Blog 196

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

1004 Counting Leaves (30 point(s)) - C语言 PAT 甲级

设计思路: BFS 1. 邻接链表(数据较少,直接用了二维数组模拟)存取树 2. 队列(一维数组模拟)实现 DFS,根节点入队 3. 节点出队时,根据有无孩子进队 * 无孩子节点进队,累加当前层的叶子节点数 * 有孩子节点进队,根据出队父亲节点的层数,记录孩子节点的层数 4. 输出每一层的叶子节点数 注:不能在建立树的过程中根据父亲节点记录孩子节点的层数,因为题目未保证输入节点的过程有序,所以不能保证当前的父亲节点已经记录了自己的层数

有三只土豆 362

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

1004 Counting Leaves (30 point(s))

1004 Counting Leaves (30 point(s)) A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Example: #include<iostream> #include<vector> #include<map> #include<queue&g

专栏 137

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

1004 Counting Leaves (30)(30 point(s))

problem A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Input Each input file contains one test case. Each case starts with a...

weixin_30338461的博客 133

PAT (Advanced Level) Practice 1004 Counting Leaves (30 point(s))

题目:PAT 甲 1004 题目大意 给出一棵族谱树,问从从根节点的最顶层到最底层,每一层的叶子数是多少 解题思路 DFS #include<bits/stdc++.h> using namespace std; const int maxn=101; vector<vector<int>>tree(maxn); int Level_leaf[maxn],maxDeep=-1; int n,m; void dfs(int f,int deep){ maxDe

helloful的博客 152

[PAT] 1004 Counting Leaves (30 分)Java

A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Input Specification: Each input file contains one test case. Each case s...

Simma1101的博客 356

PAT甲级 1004 Counting Leaves——并查集应用

Counting Leaves 原题链接 题目描述: 给你一个家族树,要求你输出树的每一层中叶子节点个数,数据范围(1—99)。 思路如下: 申请一个大小为100的数组,对于每个输入构造并查集,循环一次即可得到每一个节点的层次; 申请一个大小为100的bool型数组,初值为false,有后代时设置为true(区分叶子节点) 最后再次循环把叶子节点按层次计数输出即可 AC代码 #include ...

adventural的博客 195

[PAT]1004. Counting Leaves (30)@Java

1004. Counting Leaves (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A family hierarchy is usually presented by a

zjkC050818的博客 711

1004 Counting Leaves (30)(30 point(s)

1004 Counting Leaves (30)(30 point(s))Questions A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Input Each input file contai...

Cute_jinx的博客 332

1004 Counting Leaves (30)(30 分)

A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Input Each input file contains one test case. Each case starts with a line co...

qq_42232708的博客 307

PAT 1004 Counting Leaves (30)(30 分)

A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Input Each input file contains one test case. Each case starts with a line co...

Maple的博客 258

PAT甲级--1004 Counting Leaves(30 分)【层次遍历+dfs】

1004 Counting Leaves(30 分) A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Input Specification: Each input file contains one...

Imagirl1的博客 691
上一篇: 1072 Gas Station (30 point(s))
下一篇: 1020 Tree Traversals (25 point(s))
coderwait
博客等级 码龄9年 20粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值