Chocolate NF Spring

查看题解 查看答案
题目描述
Time Limit: 1000 ms
Memory Limit: 256 mb
  • Nongfu spring has a complex water supply system. There are some water sources, and Water from the source enters the pipe
  • .Mineral water flows into some processing points through the pipe, and finally flows into the packaging point, for packaging.We think of the water source, the processing point, the packaging point as nodes, and there are N nodes and n-1 pipes connecting them.  (2 <= N <= 100,000)Recently, nongfu spring wanted to introduce chocolate-flavored water. To save costs, nongfu spring wanted to install the chocolate injection device at just one node. In other words, they wanted to put the chocolate injection device on a node where all the mineral water would flow past.Help nongfu spring find all possible nodes. As a reminder, the chocolate injection device may be installed in a water source or packaging plant

Let's take an example.

  • where nodes 1, 2 and 3 are water sources, 4, 5, 6 and 7 are processing plants, and 8 and 9 are packaging fields.The chocolate injector can be mounted on no6 and no7 becouse all the water flows through them
输入输出格式
输入描述:
A single integer: N There are n - 1 lines , Each line contains two space-separated integers that describe a pipe's connectivity: Ai and Bi
输出描述:
Integers, one per line and in ascending order, each denoting a possible node at which to install the chocolate inserter.
输入输出样例
输入样例#:
9 
1 4 
3 5 
2 4 
5 6 
6 7 
7 8 
4 6 
7 9
输出样例#:
复制
6 
7
编辑器外观×
主题
字号 16px
背景
登录后免费刷此题

提交代码后在此处可查看状态