1569_howmanypa

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

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

Pro.ID

1569

Title

how many path

Title链接

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

AC

10

Submit

33

Ratio

30.30%

时间&空间限制

  • Time Limit: 20000/10000 MS (Java/Others)     Memory Limit: 131072/131072 K (Java/Others)
  • 描述

    Given an directed graph G = (V, E), and two vertices u, vV, you are asked to determine how many deferent path between u and v.

    输入

    The input begins with a line containing an integer T (T ≤ 500), which indicates the number of test cases. Each case begins with four integers N, M, u and v (2 ≤ N ≤ 10000, 0 ≤ M ≤ 100000, 1 ≤ u, vN, uv). The following M lines each consist of two integers a and b (1 ≤ a, bN, ab), indicating that arc <a, b> ∈ E.

    输出

    Description

    Given an directed graph G = (V, E), and two vertices u, vV, you are asked to determine how many deferent path between u and v.

    Input

    The input begins with a line containing an integer T (T ≤ 500), which indicates the number of test cases. Each case begins with four integers N, M, u and v (2 ≤ N ≤ 10000, 0 ≤ M ≤ 100000, 1 ≤ u, vN, uv). The following M lines each consist of two integers a and b (1 ≤ a, bN, ab), indicating that arc <a, b> ∈ E.

    Output

    For each case, output the number of different path from a to b .

    Sample Input

    2

    4 4 1 2
    1 3
    3 4
    4 2
    2 3

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

    Sample Output

    2
    0

    Author

    样例输入

    2

    4 4 1 2
    1 3
    3 4
    4 2
    2 3

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

    样例输出

    2
    0

    提示

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部