luogu#P8905. [USACO22DEC] Strongest Friendship Group G
[USACO22DEC] Strongest Friendship Group G
Problem Description
Farmer John has cows (), numbered . Among these cows, there are () pairs of friends.
A group of cows is called a "friend group" if, for every cow in the group, it can reach every other cow in the group by following a sequence of friendships that stays entirely within the group (friendships that connect to cows outside the group are invalid). The "strength" of a friend group is defined as:
(the minimum number of in-group friends among cows in the group) (the number of cows in the group)
(again, note that friendships connecting to cows outside the group are not counted in this definition).
Find the maximum strength among all friend groups.
Input Format
The first line contains and .
The next lines each contain two integers and , indicating that cows and are friends (, ). Each unordered pair of cows appears at most once.
Output Format
Output one line containing the maximum strength among all friend groups.
8 10
1 2
1 3
1 4
2 3
2 4
3 4
1 5
2 6
3 7
4 8
12
Hint
Explanation for Sample 1
It can be seen that the maximum strength comes from the group of cows numbered . In this group, the minimum number of friends is , so the answer is .
Test Point Properties
- For , test point satisfies .
- For , test point satisfies .
- For , test point has no additional constraints.
Translated by ChatGPT 5