Friends
시간 제한1초메모리 제한2048 MB
무향 친구 관계 그래프와 내 사용자 번호가 주어질 때, 친구 관계가 전이적이라는 규칙 아래 내가 모든 사용자와 친구인지 판정한다.
문제
A new social network has been released and as you're very into new technology, you immediately decide to join it. After creating your account, you would look who has joined the network already so you can send some friend requests. It appears this is not a regular social network like Facebook and there's one difference: when you are friends with someone, you're automatically friends with all the people he or she is also friends with. For example, if you're friends with "Jan", and "Jan" is friends with "Piet", then you are also friends with "Piet" and all other people he has as friend.
You are given the details of the network. You know which members have joined the network and which users are friends with each other. Each user has an unique identifier in the network.
More and more people are joining the new established network and you would like to know whether you're friends with everyone. After all, one can never have too much friends on a social network!
입력
The first line consists of the integers , and (, , ): is the amount of registered users in the network, denotes the number of connections in the network and is your user identifier. After that, lines follow with on each line two integers: and which means that users with identifiers and are friends in the network.
출력
One line with either if you have every other user as a friend or if not.