#P10918. 小分图最大匹配
小分图最大匹配
Problem Description
You are given a bipartite graph with some left-side vertices and right-side vertices, numbered from to .
For each left-side vertex , there is an edge parameter , meaning it connects to every such that .
Now you are given two arrays of length , meaning there are left-side vertices whose edge parameter is . In other words, this graph has a total of left-side vertices. This is a fast way to input the edge parameters of the left-side vertices.
It is guaranteed that all are pairwise distinct.
Find the maximum matching of this bipartite graph.
Input Format
The first line contains two integers and .
In the next lines, each line contains two positive integers. On the -th line, the two numbers are and .
Output Format
Output one integer in one line, which is the answer.
3 6
1 1
2 2
3 1
4
6 12
12 3
3 1
2 1
6 2
4 2
1 2
8
11 60
4 1
15 10
3 1
20 3
2 2
30 2
6 4
10 5
5 3
60 5
12 14
23
Hint
This problem uses bundled subtasks.
| Subtask | Special Property | Score | ||
|---|---|---|---|---|
| 0 | None | 10 | ||
| 1 | ||||
| 2 | Yes | 20 | ||
| 3 | None | |||
| 4 | Yes | |||
| 5 | None | |||
For all testdata, it is guaranteed that $1\le n \le 7\times10^3, 1\le m \le 10^{12},1\le a_i \le m,0\le c_i \le 10^{12}$.
Special property: it is guaranteed that .
Here is the Möbius function, defined as
$$\mu(n)=\left\{\begin{array}{ll} 1 & n=1 \\ 0 & n \text { 含有平方因子 } \\ (-1)^{k} & k \text { 为 } n \text { 的本质不同质因子个数 } \end{array}\right.$$For all testdata, it is guaranteed that all are pairwise distinct.
Translated by ChatGPT 5