#P14090. [ICPC 2023 Seoul R] Lucky Draws
[ICPC 2023 Seoul R] Lucky Draws
题目描述
The ICPC committee is planning a surprise event to cheer on the participating teams. The committee provides each team with a pair of two numbers, and (), before the competition, which will be used for the lucky draws after the competition. The committee wants to hold draws. In each draw, a single number is chosen by the committee, and all teams with a pair such that win in this draw. To make more teams happy, the committee wants to choose the numbers used in the draws in advance so that the most teams win. A team can win multiple times but is considered to have won once.
For example, five teams are participating in ICPC and their pairs are , and . When the committee chooses two numbers and , four teams with and win. The team with wins twice because the pair contains both chosen numbers. In fact, all five teams can win if and are chosen. The maximum number of winning teams is five.
Given pairs of two integers for teams and the number of lucky draws , write a program to output the maximum number of winning teams.
输入格式
Your program is to read from standard input. The input starts with a line containing two integers, and ($1 \le n\le 10,000, 1 \le K\le n, 1 \le n\times K\le 500,000$), where is the number of teams and is the number of lucky draws. Each of the following lines contains two integers and that represent the pair of a team, where .
输出格式
Your program is to write to standard output. Print exactly one line. The line should contain the maximum number of winning teams. Teams that win more than once should only be counted once.
5 2
1 2
1 4
3 6
4 7
5 6
5
3 2
2 4
1 3
3 5
3
4 1
2 3
1 1
4 5
4 5
2
7 2
5 6
7 9
7 7
1 4
2 3
4 7
4 7
6