Instagraph
시간 제한: 6000ms메모리 제한: 2048MB출처: NCPC 2025BOJ 35224
문제
A celebrity in a social network is somebody with many followers, but who doesn't follow them back. More precisely, a person is a celebrity for a group of people, if
- every member of the group follows the person,
- the person follows nobody in the group.
The celebrity centrality of person , written , is the maximum size of such a group.
We model the social network as a directed graph with vertices , , . A directed edge from to means that person follows person . For example, in
we have , , and .
Your task is to find a vertex with the maximum celebrity centrality . In case of a tie, choose the smallest .
입력
The input consists of
- One line with two integers and (, ), the number of vertices and the number of directed edges.
- lines with two distinct integers and (), indicating a directed edge from to . There are no duplicate edges.
출력
Output two integers: the smallest with the maximum celebrity centrality and the value .
예제
예제 1
입력
6 8 1 2 2 1 2 3 3 2 3 6 4 5 5 2 6 5
출력
5 2
예제 2
입력
1 0
출력
1 0
코드를 제출하려면 로그인하세요.