CF958B1.Maximum Control (easy)

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The Resistance is trying to take control over all planets in a particular solar system. This solar system is shaped like a tree. More precisely, some planets are connected by bidirectional hyperspace tunnels in such a way that there is a path between every pair of the planets, but removing any tunnel would disconnect some of them.

The Resistance already has measures in place that will, when the time is right, enable them to control every planet that is not remote. A planet is considered to be remote if it is connected to the rest of the planets only via a single hyperspace tunnel.

How much work is there left to be done: that is, how many remote planets are there?

输入格式

The first line of the input contains an integer NN ( 2<=N<=10002<=N<=1000 ) – the number of planets in the galaxy.

The next N1N-1 lines describe the hyperspace tunnels between the planets. Each of the N1N-1 lines contains two space-separated integers uu and vv ( 1<=u,v<=N1<=u,v<=N ) indicating that there is a bidirectional hyperspace tunnel between the planets uu and vv . It is guaranteed that every two planets are connected by a path of tunnels, and that each tunnel connects a different pair of planets.

输出格式

A single integer denoting the number of remote planets.

输入输出样例

  • 输入#1

    5
    4 1
    4 2
    1 3
    1 5
    

    输出#1

    3
    
  • 输入#2

    4
    1 2
    4 3
    1 4
    

    输出#2

    2
    

说明/提示

In the first example, only planets 22 , 33 and 55 are connected by a single tunnel.

In the second example, the remote planets are 22 and 33 .

Note that this problem has only two versions – easy and medium.

首页