Strongest Friendship Group
시간 제한2초메모리 제한1024 MB
무방향 그래프가 주어질 때, 한 연결된 묶음을 골라 (묶음 크기) 곱하기 (묶음 안에서 각 소의 최소 연결 수)를 최대로 만드는 값을 구한다.
문제
Farmer John has cows (), conveniently labeled . There are () pairs of friends among these cows.
A group of cows is called a "friendship group" if every cow in the group is reachable from every other cow in the group via a chain of friendships that lies solely within the group (friendships connecting to cows outside the group have no impact). The "strength" of a friendship group is the minimum number of friends of any cow in the group within the group times the number of cows in the group (again, note that friendships connecting to cows outside the group do not count for this definition).
Please find the maximum strength over all friendship groups.
입력
The first line contains and .
The next lines contain two integers and denoting that cows and are friends (, ). No unordered pair of cows appears more than once.
출력
One line containing the maximum strength over all friendship groups.
힌트
The maximum strength can be observed to be with the group of cows numbered . The minimum number of friends of any cow in this group within the group is , so the answer is .