[POI2014] RAJ-Rally


### 题目描述 给定一个 $n$ 个点 $m$ 条边的有向无环图,每条边长度都是 $1$。 请找到一个点,使得删掉这个点后剩余的图中的最长路径最短。 ### 输入格式 第一行包含两个正整数 $n$,$m$($2\le n\le5\times10^5$,$1\le m\le10^6$),表示点数、边数。 接下来 $m$ 行每行包含两个正整数 $a_i,b_i$($1\le a_i,b_i\le n,a_i\ne b_i$),表示 $a_i$ 到 $b_i$ 有一条边。 ### 输出格式 包含一行两个整数 $x$,$y$,用一个空格隔开,$x$ 为要删去的点,$y$ 为删除 $x$ 后图中的最长路径的长度,如果有多组解请输出任意一组。


An annual bicycle rally will soon begin in Byteburg. The bikers of Byteburg are natural long distance cyclists. Local representatives of motorcyclists, long feuding the cyclists, have decided to sabotage the event. There are ![](http://main.edu.pl/images/OI21/raj-en-tex.1.png) intersections in Byteburg, connected with one way streets. Strangely enough, there are no cycles in the street network - if one can ride from intersection ![](http://main.edu.pl/images/OI21/raj-en-tex.2.png) to intersection ![](http://main.edu.pl/images/OI21/raj-en-tex.3.png), then it is definitely impossible to get from ![](http://main.edu.pl/images/OI21/raj-en-tex.4.png) to ![](http://main.edu.pl/images/OI21/raj-en-tex.5.png). The rally's route will lead through Byteburg's streets. The motorcyclists plan to ride their blazing machines in the early morning of the rally day to one intersection and completely block it. The cyclists' association will then of course determine an alternative route but it could happen that this new route will be relatively short, and the cyclists will thus be unable to exhibit their remarkable endurance. Clearly, this is the motorcyclists' plan - they intend to block such an intersection that the longest route that does not pass through it is as short as



In the first line of the standard input, there are two integers, N and M(2<=N<=500 000,1<=M<=1 000 000), separated by a single space, that specify the number of intersections and streets in Byteburg. The intersections are numbered from to . The lines that follow describe the street network: in the -th of these lines, there are two integers, Ai, Bi(1<=Ai,Bi<=N,Ai<>Bi), separated by a single space, that signify that there is a one way street from the intersection no. Ai to the one no. Bi


The first and only line of the standard output should contain two integers separated by a single space. The first of these should be the number of the intersection that the motorcyclists should block, and the second - the maximum number of streets that the cyclists can then ride along in their rally. If there are many solutions, your program can choose one of them arbitrarily.


输入样例 #1

6 5
1 3
1 4
3 6
3 4
4 5

输出样例 #1

1 2


感谢@zyh2015 提供spj