21832_Arres

2022-5-16 18:20| 发布者: Hocassian| 查看: 23| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505885444400-Problem List-采集的数据-后羿采集器.html

Pro.ID

21832

Title

Arrest

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21832

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/32768 K (Java/Others)
  • 描述

    Country ALPC has n cities, and the cities are connected by undirected roads. Furthermore, there is exactly one route between each pair of cities. Now some criminals break the prison and the police do not know where they are. And the criminals can stay in a city or move on the roads. The police office has made a decision to send policemen to arrest the breakers. If a police and a criminal at a same point at the same time the criminal is under arrest, no matter in a city or on a road. The police office wants to minimize the number of policemen to arrest all the criminals. Now the map of Country ALPC is given, please tell the police office the least number of policemen required.

    输入

    There are several test cases.

    The first line a integer n, the number of cities. Next n-1 lines each two integers a and b, there is a road between city a and city b.

    ( 1 ≤ n ≤ 1000 ,  1 ≤ a, bn )

    输出

    Description

    Country ALPC has n cities, and the cities are connected by undirected roads. Furthermore, there is exactly one route between each pair of cities. Now some criminals break the prison and the police do not know where they are. And the criminals can stay in a city or move on the roads. The police office has made a decision to send policemen to arrest the breakers. If a police and a criminal at a same point at the same time the criminal is under arrest, no matter in a city or on a road. The police office wants to minimize the number of policemen to arrest all the criminals. Now the map of Country ALPC is given, please tell the police office the least number of policemen required.

    Input

    There are several test cases.

    The first line a integer n, the number of cities. Next n-1 lines each two integers a and b, there is a road between city a and city b.

    ( 1 ≤ n ≤ 1000 ,  1 ≤ a, bn )

    Output

    For each case output the minimal number of policemen.

    Sample Input

    3
    1 2
    2 3
    16
    1 2
    1 3
    1 4
    5 6
    5 7
    10 8
    8 11
    9 12
    9 13
    14 1
    14 15
    15 16
    15 8
    9 16
    14 5

    Sample Output

    1
    3

    Source

    样例输入

    3
    1 2
    2 3
    16
    1 2
    1 3
    1 4
    5 6
    5 7
    10 8
    8 11
    9 12
    9 13
    14 1
    14 15
    15 16
    15 8
    9 16
    14 5

    样例输出

    1
    3

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部