当前位置:网站首页>Class Notes (7) (1) - #647. Find the root and the child (root)
Class Notes (7) (1) - #647. Find the root and the child (root)
2022-08-10 07:42:00 【xyc20120615】
Description
Given a tree, output the root root of the tree, the node with the most children max and its children.
Format
Input
The first line: n (number of nodes≤100), m (number of edges≤200).
The following m lines; each line has two nodes x and y, indicating that y is a child of x (x,y≤100).
Output
First line: tree root: root.
The second line: the node with the most children max.
The third line: the children of max.
Samples
Enter Data 1
8 74 14 21 31 52 62 72 8
Output data 1
426 7 8
Limitation
1s, 1024KiB for each test case.
Solution:
Although the standard answer is to use a binary tree, But!I prefer a binary tree!I'm going to use tag arrays!That's right!It's that simple array of tags!
Program:
#includeusing namespace std;int m,n,f,a[110],b[210],z[110],maxn;int main(){cin>>n>>m;for(int i=1;i<=m;i++)cin>>a[i]>>b[i];for(int i=1;i<=m;i++)z[b[i]]++;for(int i=1;i<=n;i++)if(!z[i])cout<=maxn)maxn=z[i];for(f=1;f<=n;f++){if(z[f]==maxn){cout<
边栏推荐
- 图像处理用什么神经网络,神经网络提取图片特征
- What is an MQTT gateway?What is the difference with traditional DTU?
- 协同工具满足70%-90%的工作需求,成为企业香饽饽
- 3.1-3.3 读书笔记
- 软件测试面试题避雷(HR面试题)最常见的面试问题和技巧性答复
- Synchronization lock synchronized traces the source
- IDLE development wordCount program (5)
- 2022-08-01 网工进阶(二十四) STP进阶知识
- The precise effect of network integration promotion outsourcing in the era of Internet of Things-Shenzhen Win-Win World News
- 手把手教你进行Mysql查询操作
猜你喜欢
IDLE development wordCount program (5)
自动化测试框架Pytest(一)——入门
时序动作定位 | ASM-Loc:弱监督时序动作定位的动作感知片段建模(CVPR 2022)
杭州公积金修改手机号信息
【Rust指南】使用Cargo工具高效创建Rust项目 | 理解Rust特别的输入输出语句
Synchronization lock synchronized traces the source
自动化测试框架搭建 ---- 标记性能较差用例
DGIOT 30 million meters set pressure reading
初使jest 单元测试
张驰课堂:老板会武术,谁也挡不住!六西格玛培训的魅力
随机推荐
2022-08-01 网工进阶(二十三) VLAN高级技术-VLAN聚合、MUX VLAN
如何远程调试对方的H5页面
概率分布及其应用
SQL SERVER 数据库,表的数据发生增删改,该表的索引会在ldf日志中记录吗?
winget package manager
人工神经网络工作原理,神经网络的工作原理
自动化测试框架Pytest(二)——前后置处理
Rust学习:6.5_复合类型之数组
DGIOT supports industrial equipment rental and remote control
The precise effect of network integration promotion outsourcing in the era of Internet of Things-Shenzhen Win-Win World News
DGIOT支持工业设备租赁以及远程管控
浅谈C语言实现冒泡排序
英国国家卫生服务遭受攻击,系统出现大面积故障
C# 获取PCI等设备的插槽位置信息
ATH10传感器读取温湿度
PLSQL学习第二天
2022-08-01 Advanced Network Engineering (24) STP Advanced Knowledge
物联网时代下的网络整合推广外包精准化效果-深圳双赢世讯
全连接神经网络结构图,神经网络示意图怎么画
phpstudy开机自启