0101少儿编程
Home
ProblemSet
Source/Category
Contest
Status
Ranklist
F.A.Qs
IDE下载
Login
Register
13317: 树的数量
Memory Limit:128 MB
Time Limit:1.000 S
Judge Style:Text Compare
Creator:
Submit:2
Solved:0
Submit
Submit Record
Statistics
ShowOff!
Description
输入森林中的结点关系,统计森林中树的数量,输出树的根。
Input
第一行:
n
:结点数量;
k
:边数;(
n,k<=100
)
以下
k
行:每行两个结点编号:
i
,
j
:
i
是
j
的父结点
(I,j<=100)
。
Output
输出:
第一行:树的数量。
第二行:依次输出森林中树的根结点编号(从小到大)。
Sample Input
Copy
9 7 1 2 2 3 4 6 4 5 7 8 9 1 9 4
Sample Output
Copy
2 7 9
Source/Category
数据结构-树结构
洛谷
Submit
Submit Record
Statistics
ShowOff!