1338_CowTraffic

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

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

Pro.ID

1338

Title

Cow Traffic

Title链接

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

AC

20

Submit

86

Ratio

23.26%

时间&空间限制

  • Time Limit: 600/200 MS (Java/Others)     Memory Limit: 65536/131072 K (Java/Others)
  • 描述

    The bovine population boom down on the farm has caused serious congestion on the cow trails leading to the barn. Farmer John has decided to conduct a study to find the bottlenecks in order to relieve the 'traffic jams' at milking time.

    The pasture contains a network of M (1 ≤ M ≤ 50,000) one-way trails, each of which connects exactly two different intersections from the set of N (1 ≤ N ≤ 5,000) intersections conveniently numbered 1..N; the barn is at intersection number N. Each trail connects one intersection point to another intersection point with a higher number. As a result, there are no cycles and, as they say on the farm, all trails lead to the barn. A pair of intersection points might be connected by more than one trail.

    During milking time rush hour, the cows start from their respective grazing locations and head to the barn. The grazing locations are exactly those intersection points with no trails connecting into them. Each cow traverses a 'path', which is defined as a sequence of trails from a grazing location to the barn.

    Help FJ finding the busiest trail(s) by computing the largest number of possible paths that contain any one trail. The answer is guaranteed to fit in a signed 32-bit integer.

    输入

    Line 1:             Two space-separated integers: N and M.

    Lines 2 .. M+1:   Two space-separated intersection points.

    输出

    Description

    The bovine population boom down on the farm has caused serious congestion on the cow trails leading to the barn. Farmer John has decided to conduct a study to find the bottlenecks in order to relieve the 'traffic jams' at milking time.

    The pasture contains a network of M (1 ≤ M ≤ 50,000) one-way trails, each of which connects exactly two different intersections from the set of N (1 ≤ N ≤ 5,000) intersections conveniently numbered 1..N; the barn is at intersection number N. Each trail connects one intersection point to another intersection point with a higher number. As a result, there are no cycles and, as they say on the farm, all trails lead to the barn. A pair of intersection points might be connected by more than one trail.

    During milking time rush hour, the cows start from their respective grazing locations and head to the barn. The grazing locations are exactly those intersection points with no trails connecting into them. Each cow traverses a 'path', which is defined as a sequence of trails from a grazing location to the barn.

    Help FJ finding the busiest trail(s) by computing the largest number of possible paths that contain any one trail. The answer is guaranteed to fit in a signed 32-bit integer.

    Input

    Line 1:             Two space-separated integers: N and M.

    Lines 2 .. M+1:   Two space-separated intersection points.

    Output

    Line 1:   The maximum number of paths passing through any one trail.

    Sample Input

    7 7
    1 3
    3 4
    3 5
    4 6
    2 3
    5 6
    6 7

    Sample Output

    4

    Hint

    Here are the four possible paths that lead to the barn:

    1 3 4 6 7
    1 3 5 6 7
    2 3 4 6 7
    2 3 5 6 7

    Source

    样例输入

    7 7
    1 3
    3 4
    3 5
    4 6
    2 3
    5 6
    6 7

    样例输出

    4

    提示

    Here are the four possible paths that lead to the barn:

    1 3 4 6 7
    1 3 5 6 7
    2 3 4 6 7
    2 3 5 6 7


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部