PAT 甲级 1021. Deepest Root (25)
来源:互联网 发布:淘宝第四层级金额 编辑:程序博客网 时间:2024/06/01 10:27
A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root that results in a highest tree. Such a root is called the deepest root.
Input Specification:
Each input file contains one test case. For each case, the first line contains a positive integer N (<=10000) which is the number of nodes, and hence the nodes are numbered from 1 to N. Then N-1 lines follow, each describes an edge by given the two adjacent nodes' numbers.
Output Specification:
For each test case, print each of the deepest roots in a line. If such a root is not unique, print them in increasing order of their numbers. In case that the given graph is not a tree, print "Error: K components" where K is the number of connected components in the graph.
Sample Input 1:51 21 31 42 5Sample Output 1:
345Sample Input 2:
51 31 42 53 4Sample Output 2:
Error: 2 components
- 【PAT甲级】1021. Deepest Root (25)
- PAT甲级练习1021. Deepest Root (25)
- 1021. Deepest Root (25) PAT 甲级
- PAT甲级1021. Deepest Root (25)
- PAT 甲级 1021. Deepest Root (25)
- PAT 甲级1021. Deepest Root (25)
- [PAT-甲级]1021.Deepest Root
- PAT 甲级 Deepest Root (25)
- PAT甲级练习题A1021. Deepest Root (25)
- 1021. Deepest Root (25)-PAT
- PAT 1021. Deepest Root (25)
- PAT 1021. Deepest Root (25)
- PAT 1021. Deepest Root (25)
- PAT 1021. Deepest Root (25)
- PAT 1021. Deepest Root (25)
- 【PAT】1021. Deepest Root (25)
- pat 1021. Deepest Root (25)
- 【PAT】1021. Deepest Root (25)
- java集合
- 剑指offer之查找
- xml文件格式化
- TensorFlow深度学习,一篇文章就够了
- modbus4j,rtu,ascii,tcp/ip传输模式
- PAT 甲级 1021. Deepest Root (25)
- 页面加载自动生成meta标签,做屏幕自适应功能
- 高德地图纠偏不准,祭出我自己的纠偏算法
- 推荐几个精致的前端web UI框架
- 大数相加
- kotlin集合操作符——总数操作符
- ES6 箭头函数链式调用
- 谈一谈java中对象的排序
- python抓取网页中图片并保存到本地