Death Gun

View as PDF

Submit solution

Points: 7 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Death Gun is wreaking havoc in the world of SAO::J, and must be stopped! As the protagonist, it is your duty to hunt him down and prevent any more innocent gamers from being Log-offed! However, Death Gun is adept at hiding and has disguised himself as one of the users in the judge! You know that Death Gun, whoever he/she is, has an extensive information network, and some certain people may know their identity. You have obtained this information network from the admins of SAO::J, in the form of a list with M items. Each item on the list is actually just a relation between user a and b. If you go to ask a who death gun is, he/she will simply redirect you to user b and then ask you to see them again; unless, you've already visited b in which case they will gladly tell you their information. To save time, you would like to find out an order to visit all the users on your list so that you do not waste time being redirected. If there are multiple ways to do so, output the people who appear on the list before those that appear later. If you think you will be going in a loop at any point in your list, you should avoid that group of people altogether, as they may be trolls (don't output their names)! Also, if there is someone that tells you to visit someone that you won't visit due to loops, (or someone who is someone who wants you to visit someone that you don't want to visit due to loops, or etc.), don't visit them.

Note: A person may have several different people they want you to visit first.

Input Specification

Line 1: 1 Integer M, the number of items on your list (1 \le M \le 900)

Next M lines: 2 strings (with no spaces), space separated - A and B

Output Specification

On each line i, output the name of the ith person you should visit on your list.

Sample Input

3
Fataleagle Quantum
Quantum Xyene
Xyene DefinitelyNotDeathGun

Sample Output

DefinitelyNotDeathGun
Xyene
Quantum
Fataleagle

Explanation for Sample

If you go to Fataleagle, he will redirect you to Quantum, who will redirect you to Xyene, who will redirect you to DefinitelyNotDeathGun. Therefore you should visit DefinitelyNotDeathGun first, then Xyene since you've already visited DefinitelyNotDeathGun, Quantum since you've visited Xyene, and then Fataleagle since you've visited Quantum.


Comments


  • 5
    YouZ  commented on Dec. 7, 2015, 9:50 p.m.

    Lol I know a bunch of the people you used for test cases. They go to my school


  • 0
    bobhob314  commented on Nov. 2, 2015, 9:12 p.m.

    This was especially confusing to understand. Could anyone help me out? (or someone who is someone who wants you to visit someone that you don't want to visit due to loops, or etc.)


    • 0
      awaykened  commented on Nov. 2, 2015, 11:05 p.m.

      edges are not bidirectional, don't output cycles :)


  • 0
    bobhob314  commented on Nov. 2, 2015, 9:07 p.m.

    Hey all,

    I was hoping for some clarification on this.

    Also, if there is someone that tells you to visit someone that you won't visit due to loops, (or someone who is someone who wants you to visit someone that you don't want to visit due to loops, or etc.), don't visit them.

    Is this trying to say that all people in a connected component with a cycle should be avoided? Or is it that if the edges were all bidirectional, all people in a connected component that has a cycle should be avoided?

    So if we have

    3

    1 2

    2 1

    1 3

    Should we avoid 3?

    And if we have

    3

    1 2

    2 1

    3 1

    Should we avoid 3?


  • 2
    bobhob314  commented on April 1, 2015, 6:31 p.m. edit 2

    Can it be?

    alt text


    Edit: The lack of nested replies makes my humour a lot harder to get.


  • 0
    awaykened  commented on April 1, 2015, 4:08 p.m.

    also, I've reworded the problem. rejudged again :D


  • 0
    awaykened  commented on April 1, 2015, 4:05 p.m.

    your submission has been rejudged.


  • 0
    bobhob314  commented on April 1, 2015, 4:01 p.m.

    Same thing happened to me. I think the judge is faulty.


  • 26
    nullptr  commented on April 1, 2015, 4:00 p.m.

    The statement says not to visit someone if you don't want to. I don't want to visit anyone, but when I submitted a program that outputs an empty file, it was marked WA.


  • 4
    Xyene  commented on April 1, 2015, 11:52 a.m.

    test


  • -1
    awaykened  commented on April 1, 2015, 6:43 a.m.

    ...................... comments are not nesting


  • -1
    awaykened  commented on April 1, 2015, 6:41 a.m.

    NO!

    jk yes


  • -1
    awaykened  commented on April 1, 2015, 6:40 a.m. edited

    HINT:

    use a right triangle


  • 2
    du1997du  commented on April 1, 2015, 1:11 a.m.

    Is it possible for one user to redirect to multiple users?