can pay one dollar to the sock store to all things considered: recolor a sock to any tone c′ (1≤c′≤n) transform a left sock into a right sock transform a right sock into a left sock The sock store might play out every one of these progressions
Computer science. Correct answer will be upvoted else downvoted.
Phoenix can pay one dollar to the sock store to all things considered:
recolor a sock to any tone c′ (1≤c′≤n)
transform a left sock into a right sock
transform a right sock into a left sock
The sock store might play out every one of these progressions quite a few times. Note that the shade of a left sock doesn't change when it transforms into a right sock, as well as the other way around.
A coordinating with pair of socks is a left and right sock with a similar shading. What is the base expense for Phoenix to make n/2 coordinating with sets? Each sock should be remembered for precisely one coordinating with pair.
Input
The input comprises of numerous experiments. The principal line contains an integer t (1≤t≤1000) — the number of experiments.
The primary line of each experiment contains three integers n, l, and r (2≤n≤2⋅105; n is even; 0≤l,r≤n; l+r=n) — the all out number of socks, and the number of left and right socks, separately.
The following line contains n integers ci (1≤ci≤n) — the shades of the socks. The primary l socks are left socks, while the following r socks are correct socks.
It is ensured that the amount of n across all the experiments won't surpass 2⋅105.
Output
For each experiment, print one integer — the base expense for Phoenix to make n/2 coordinating with sets. Each sock should be remembered for precisely one coordinating with pair.
Step by step
Solved in 3 steps with 1 images