22786_FieldPlan

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

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

Pro.ID

22786

Title

Field Plan

Title链接

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

AC

16

Submit

28

Ratio

57.14%

时间&空间限制

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

    WorldSoccer Championship is coming soon and coach Yogi wants to prepare his team aswell as possible. So he made up a strategy field plan for every player of theteam. One plan describes a number of possible locations for the player on the field.Moreover, if Yogi wants the player to be able to move from one location A toanother location B then the plan specifies the ordered pair (A,B). He is surethat his team will win if the players run over the field from one location toanother using only moves of the plan.

    Yogi tells every player to follow his plan and to startfrom a location that reaches every other location on the plan (by possiblymultiple moves). However, it is quite dificult for some soccer players, simple mindedas they are, to find a suitable starting location. Can you help every player tofigure out the set of possible start locations?

    输入

    Thefirst line gives the number of field plans. The input contains at most eleven field plans (what else?). Every plan starts with a line of two integers N and M, with 1 ≤ N ≤ 100000 and 1 ≤ M ≤ 100000, giving the number of locations and the number of moves. In the following M lines a plan specifies moves (A, B) by two white space separated integers 0 ≤ A, B < N. The plans are separated by a blank line.

    输出

    Description

    WorldSoccer Championship is coming soon and coach Yogi wants to prepare his team aswell as possible. So he made up a strategy field plan for every player of theteam. One plan describes a number of possible locations for the player on the field.Moreover, if Yogi wants the player to be able to move from one location A toanother location B then the plan specifies the ordered pair (A,B). He is surethat his team will win if the players run over the field from one location toanother using only moves of the plan.

    Yogi tells every player to follow his plan and to startfrom a location that reaches every other location on the plan (by possiblymultiple moves). However, it is quite dificult for some soccer players, simple mindedas they are, to find a suitable starting location. Can you help every player tofigure out the set of possible start locations?

    Input

    Thefirst line gives the number of field plans. The input contains at most eleven field plans (what else?). Every plan starts with a line of two integers N and M, with 1 ≤ N ≤ 100000 and 1 ≤ M ≤ 100000, giving the number of locations and the number of moves. In the following M lines a plan specifies moves (A, B) by two white space separated integers 0 ≤ A, B < N. The plans are separated by a blank line.

    Output

    Forevery plan print out all possible starting locations, sorted increasingly and one per line. If there are no possible locations to start, print "Confused". Print a blank line after each plan output.

    Sample Input

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

    Sample Output

    0
    1
    2

    Confused

    Source

    样例输入

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

    样例输出

    0
    1
    2

    Confused

    提示

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部