#P4477. [BJWC2018] 基础匹配算法练习题
[BJWC2018] 基础匹配算法练习题
Description
Xiao S recently learned the Hungarian algorithm for bipartite matching.
Now the X part of a bipartite graph has numbers , and the Y part has numbers .
If , then there is an edge between and . Find the maximum matching size of the bipartite graph .
Xiao S is a beginner, so she wants to do more practice to consolidate her knowledge. She found a positive integer array of length . Each time, she picks a continuous subarray from , takes all numbers in as the numbers on the Y part of the bipartite graph, and then recomputes the maximum matching size.
Xiao S plans to do practice sessions, but she is not sure whether each computed answer is correct. Can you help her?
Input Format
The first line contains three positive integers .
The second line contains positive integers, where the -th integer is .
The third line contains positive integers, where the -th integer is .
The fourth line contains an integer denoting the number of queries.
Each of the next lines contains two positive integers; on the -th line, the two integers are .
Output Format
For each practice session, output the answer for that session.
4 10 8
1 2 4 6
6 3 6 2 8 4 9 10 6 8
4
1 4
2 5
5 6
1 6
4
3
1
4
Hint
| Testdata ID | |||
|---|---|---|---|
For of the testdata, , .
The testdata is graded.
Translated by ChatGPT 5
京公网安备 11011102002149号