Close friends

Report a typo

Alice, Bob, Mike, Sam, Kate, John, Andrew, Ann, and Tom have accounts in a social network. Alice follows Bob, Sam follows Kate, Mike, and Alice, Ann follows Andrew and Sam, Andrew follows Tom, Tom follows Ann and Kate, Bob follows Mike, Kate follows John, Mike follows Alice, John follows Sam. Let's say that a group of people are close friends if they belong to one strongly connected component in a directed graph built according to the described follow relationship. Find all groups of close friends among these people and print them in the field below. The expected output format is the following:

Bob Andrew
Alice Mike

Here, each line represents a group of close friends; people in a group are separated by space.

Enter a short text
___

Create a free account to access the full topic