logo AlgoBeat OnlineJudge
登录 注册

#214640. [NCPC 2025] Instagraph

内存限制:1024 MiB 时间限制:4000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

:::align{center} :::

A celebrity in a social network is somebody with many followers, but who doesn't follow them back. More precisely, a person is a for a group of people, if

  • every member of the group follows the person,
  • the person follows nobody in the group.

The 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

:::align{center} :::

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

样例输出 1

5 2

样例输入 2

1 0

样例输出 2

1 0